แก้ไข

แชร์ผ่าน


PreAllocatedOverlapped.UnsafeCreate Method

Definition

Important

This API is not CLS-compliant.

Initializes a new instance of the PreAllocatedOverlapped class, specifying a delegate that is invoked when each asynchronous I/O operation is complete, a user-provided object providing context, and managed objects that serve as buffers.

public:
 static System::Threading::PreAllocatedOverlapped ^ UnsafeCreate(System::Threading::IOCompletionCallback ^ callback, System::Object ^ state, System::Object ^ pinData);
[System.CLSCompliant(false)]
public static System.Threading.PreAllocatedOverlapped UnsafeCreate (System.Threading.IOCompletionCallback callback, object? state, object? pinData);
[<System.CLSCompliant(false)>]
static member UnsafeCreate : System.Threading.IOCompletionCallback * obj * obj -> System.Threading.PreAllocatedOverlapped
Public Shared Function UnsafeCreate (callback As IOCompletionCallback, state As Object, pinData As Object) As PreAllocatedOverlapped

Parameters

callback
IOCompletionCallback

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

state
Object

A user-provided object that distinguishes NativeOverlapped instance produced from this object from other NativeOverlapped instances. Can be null.

pinData
Object

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

Returns

The new PreAllocatedOverlapped instance.

Attributes

Exceptions

callback is null.

This method was called after the ThreadPoolBoundHandle was disposed.

Remarks

The new PreAllocatedOverlapped instance can be passed to AllocateNativeOverlapped(PreAllocatedOverlapped), to produce a NativeOverlapped instance that can be passed to the operating system in overlapped I/O operations. A single PreAllocatedOverlapped instance can only be used for a single native I/O operation at a time. However, the state stored in the PreAllocatedOverlapped instance can be reused for subsequent native operations. ExecutionContext is not flowed to the invocation of the callback.

Note

The buffers specified in pinData are pinned until Dispose() is called.

Applies to