private static unsafe void CompletionCallback(uint errorCode, uint numBytes, NativeOverlapped* nativeOverlapped)
{
ThreadPoolBoundHandleOverlapped overlapped = (ThreadPoolBoundHandleOverlapped)Overlapped.Unpack(nativeOverlapped);
//
// The Win32 thread pool implementation of ThreadPoolBoundHandle does not permit reuse of NativeOverlapped
// pointers without freeing them and allocating new a new one. We need to ensure that code using the CLR
// ThreadPool implementation follows those rules.
//
if (overlapped._completed)
throw new InvalidOperationException(SR.InvalidOperation_NativeOverlappedReused);
overlapped._completed = true;
if (overlapped._boundHandle == null)
throw new InvalidOperationException(SR.Argument_NativeOverlappedAlreadyFree);
overlapped._userCallback(errorCode, numBytes, nativeOverlapped);
}