Overlapped.UnsafePack 方法

定义

将当前实例打包为一个 NativeOverlapped 结构。 不传播该调用堆栈。

重载

UnsafePack(IOCompletionCallback)
已过时.
已过时.
已过时.

将当前实例打包为一个 NativeOverlapped 结构,并指定当异步 I/O 操作完成时调用的委托。 不传播该调用堆栈。

UnsafePack(IOCompletionCallback, Object)

将当前实例打包为一个 NativeOverlapped 结构,并指定当异步 I/O 操作完成时调用的委托,以及作为缓冲区的托管对象。 不传播该调用堆栈。

UnsafePack(IOCompletionCallback)

Source:
Overlapped.cs
Source:
Overlapped.cs
Source:
Overlapped.cs

注意

This method is not safe. Use UnsafePack (iocb, userData) instead. https://go.microsoft.com/fwlink/?linkid=14202

注意

This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.

注意

This method is not safe. Use UnsafePack (iocb, userData) instead. http://go.microsoft.com/fwlink/?linkid=14202

重要

此 API 不符合 CLS。

将当前实例打包为一个 NativeOverlapped 结构,并指定当异步 I/O 操作完成时调用的委托。 不传播该调用堆栈。

public:
 System::Threading::NativeOverlapped* UnsafePack(System::Threading::IOCompletionCallback ^ iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
[System.Security.SecurityCritical]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
[<System.Security.SecurityCritical>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>

参数

iocb
IOCompletionCallback

一个 IOCompletionCallback 委托,表示在异步 I/O 操作完成时调用的回调方法。

返回

一个指向 NativeOverlapped 结构的非托管指针。

属性

例外

已对当前的 Overlapped 打包。

注解

此方法返回的非托管指针可以通过重叠的 I/O 操作传递给操作系统。 在调用 之前Unpack,结构NativeOverlapped在物理内存中是固定的。

调用方负责固定缓冲区。 但是,如果卸载应用程序域,则会销毁固定缓冲区的句柄并释放缓冲区,使 I/O 操作写入释放的地址。 因此,最好使用 UnsafePack(IOCompletionCallback, Object) 方法重载,运行时在其中固定缓冲区。

注意

UnsafePack使用 方法可能会无意中打开安全漏洞。 代码访问安全性基于堆栈上所有调用方的权限进行权限检查。 方法 UnsafePack 不会传播调用堆栈。 恶意代码可能会利用此漏洞来避免权限检查。

适用于

UnsafePack(IOCompletionCallback, Object)

Source:
Overlapped.cs
Source:
Overlapped.cs
Source:
Overlapped.cs

重要

此 API 不符合 CLS。

将当前实例打包为一个 NativeOverlapped 结构,并指定当异步 I/O 操作完成时调用的委托,以及作为缓冲区的托管对象。 不传播该调用堆栈。

public:
 System::Threading::NativeOverlapped* UnsafePack(System::Threading::IOCompletionCallback ^ iocb, System::Object ^ userData);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb, object? userData);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[<System.CLSCompliant(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>

参数

iocb
IOCompletionCallback

一个 IOCompletionCallback 委托,表示在异步 I/O 操作完成时调用的回调方法。

userData
Object

对象或对象的数组,表示用于操作的输入或输出缓冲区。 每个对象都表示一个缓冲区,例如字节数组。

返回

一个指向 NativeOverlapped 结构的非托管指针。

属性

例外

调用方没有所要求的权限。

已对当前的 Overlapped 打包。

注解

此方法返回的非托管指针可以通过重叠的 I/O 操作传递给操作系统。 在调用 之前Unpack,结构NativeOverlapped在物理内存中是固定的。

中指定的 userData 缓冲区或缓冲区必须与传递给执行异步 I/O 的非托管操作系统函数的缓冲区相同。

运行时在 I/O 操作期间固定 在 中指定的userData 缓冲区。 如果卸载应用程序域,运行时会一直固定内存,直到 I/O 操作完成。

注意

UnsafePack使用 方法可能会无意中打开安全漏洞。 代码访问安全性基于堆栈上所有调用方的权限进行权限检查。 方法 UnsafePack 不会传播调用堆栈。 恶意代码可能会利用此漏洞来避免权限检查。

适用于