Overlapped::UnsafePack Method (IOCompletionCallback^, Object^)
Packs the current instance into a NativeOverlapped structure, specifying the delegate to invoke when the asynchronous I/O operation is complete and the managed object that serves as a buffer. Does not propagate the calling stack.
This API is not CLS-compliant.
Assembly: mscorlib (in mscorlib.dll)
public: [SecurityCriticalAttribute] [CLSCompliantAttribute(false)] [ComVisibleAttribute(false)] NativeOverlapped* UnsafePack( IOCompletionCallback^ iocb, Object^ userData )
Parameters
- iocb
-
Type:
System.Threading::IOCompletionCallback^
An IOCompletionCallback delegate that represents the callback method invoked when the asynchronous I/O operation completes.
- userData
-
Type:
System::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.
Return Value
Type: System.Threading::NativeOverlapped*An unmanaged pointer to a NativeOverlapped structure.
| Exception | Condition |
|---|---|
| SecurityException | The caller does not have the required permission. |
| InvalidOperationException | The current Overlapped is already packed. |
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.
The runtime pins the buffer or buffers specified inuserData 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.
Caution |
|---|
Using the UnsafePack method could inadvertently open up a security hole. Code access security bases its permission checks on the permissions of all the callers on the stack. The UnsafePack method does not propagate the calling stack. Malicious code might be able to exploit this to avoid permission checks. |
Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 2.0
