internal virtual void ReleaseNativeResource()
{
// Ensure that cancellation has been completed and cleaned up.
_cancellationRegistration.Dispose();
// Free the overlapped.
// NOTE: The cancellation must *NOT* be running at this point, or it may observe freed memory
// (this is why we disposed the registration above).
if (_overlapped != null)
{
_stream._fileHandle.ThreadPoolBinding !.FreeNativeOverlapped(_overlapped);
_overlapped = null;
}
// Ensure we're no longer set as the current completion source (we may not have been to begin with).
// Only one operation at a time is eligible to use the preallocated overlapped,
_stream.CompareExchangeCurrentOverlappedOwner(null, this);
}