Overlapped.Pack Overlapped.Pack Overlapped.Pack Method

Definition

Packs the current instance into a NativeOverlapped structure.

Overloads

Pack(IOCompletionCallback) Pack(IOCompletionCallback) Pack(IOCompletionCallback)

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) Pack(IOCompletionCallback, Object) 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) Pack(IOCompletionCallback) Pack(IOCompletionCallback)

Warning

This API is now obsolete.

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("Use Pack(iocb, userData) instead")]
[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);
member this.Pack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
Parameters
iocb
IOCompletionCallback IOCompletionCallback 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.

Exceptions

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.

Security

SecurityCriticalAttribute
Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Pack(IOCompletionCallback, Object) Pack(IOCompletionCallback, Object) Pack(IOCompletionCallback, Object)

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)]
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public System.Threading.NativeOverlapped* Pack (System.Threading.IOCompletionCallback iocb, object userData);
member this.Pack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>
Parameters
iocb
IOCompletionCallback IOCompletionCallback IOCompletionCallback

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

userData
Object Object 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.

Exceptions

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.

Security

SecurityCriticalAttribute
Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Applies to