UnsafePack Method (IOCompletionCallback)

Overlapped.UnsafePack Method (IOCompletionCallback)

 
obsoleteCodeEntityM:System.Threading.Overlapped.UnsafePack(System.Threading.IOCompletionCallback,System.Object)Note: This API is now obsolete.

Packs the current instance into a NativeOverlapped structure specifying the delegate to invoke when the asynchronous I/O operation is complete. Does not propagate the calling stack.

This API is not CLS-compliant.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
[ObsoleteAttribute("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
[CLSCompliantAttribute(false)]
public unsafe NativeOverlapped* UnsafePack(
	IOCompletionCallback iocb
)

Parameters

iocb
Type: System.Threading.IOCompletionCallback

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

Return Value

Type: System.Threading.NativeOverlapped*

An unmanaged pointer to a NativeOverlapped structure.

Exception Condition
InvalidOperationException

The current Overlapped has already been 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 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 UnsafePack(IOCompletionCallback, Object) method overload, in which the runtime pins the buffer.

System_CAPS_cautionCaution

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.

SecurityCriticalAttribute

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

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft