public unsafe NativeOverlapped* AllocateNativeOverlapped(IOCompletionCallback callback, object state, object pinData)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
AddRef();
try
{
Win32ThreadPoolNativeOverlapped* overlapped = Win32ThreadPoolNativeOverlapped.Allocate(callback, state, pinData, preAllocated: null);
overlapped->Data._boundHandle = this;
Interop.Kernel32.StartThreadpoolIo(_threadPoolHandle);
return Win32ThreadPoolNativeOverlapped.ToNativeOverlapped(overlapped);
}
catch
{
Release();
throw;
}
}