ערוך

שתף באמצעות


Overlapped.Pack Method

Definition

Packs the current instance into a NativeOverlapped structure.

Overloads

Pack(IOCompletionCallback)
Obsolete.
Obsolete.
Obsolete.

Packs the current instance into a NativeOverlapped structure, specifying the delegate to be invoked when the asynchronous I/O operation is complete.

Pack(IOCompletionCallback, Object)

Packs the current instance into a NativeOverlapped structure, specifying a delegate that is invoked when the asynchronous I/O operation is complete and a managed object that serves as a buffer.

Pack(IOCompletionCallback)

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

Caution

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

Caution

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

Caution

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

Important

This API is not CLS-compliant.

Packs the current instance into a NativeOverlapped structure, specifying the delegate to be invoked when the asynchronous I/O operation is complete.

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

Parameters

iocb
IOCompletionCallback

An IOCompletionCallback delegate that represents the callback method invoked when the asynchronous I/O operation completes.

Returns

An unmanaged pointer to a NativeOverlapped structure.

Attributes

Exceptions

The current Overlapped has already been packed.

Remarks

The unmanaged pointer returned by this method can be passed to the operating system in overlapped I/O operations. The NativeOverlapped structure is fixed in physical memory until Unpack is called.

Important

The caller is responsible for pinning the buffer. If the application domain is unloaded, however, the handle to the pinned buffer is destroyed and the buffer is released, leaving the I/O operation to write to the freed address. For this reason, it is better to use the Pack(IOCompletionCallback, Object) method overload, in which the runtime pins the buffer.

Applies to

Pack(IOCompletionCallback, Object)

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

Important

This API is not CLS-compliant.

Packs the current instance into a NativeOverlapped structure, specifying a delegate that is invoked when the asynchronous I/O operation is complete and a managed object that serves as a buffer.

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

Parameters

iocb
IOCompletionCallback

An IOCompletionCallback delegate that represents the callback method invoked when the asynchronous I/O operation completes.

userData
Object

An object or array of objects representing the input or output buffer for the operation. Each object represents a buffer, for example an array of bytes.

Returns

An unmanaged pointer to a NativeOverlapped structure.

Attributes

Exceptions

The current Overlapped has already been packed.

Remarks

The unmanaged pointer returned by this method can be passed to the operating system in overlapped I/O operations. The NativeOverlapped structure is fixed in physical memory until Unpack is called.

The buffer or buffers specified in userData must be the same as those passed to the unmanaged operating system function that performs the asynchronous I/O.

Note

The runtime pins the buffer or buffers specified in userData for the duration of the I/O operation. If the application domain is unloaded, the runtime keeps the memory pinned until the I/O operation completes.

Applies to