unsafe override protected bool ReleaseHandle()
{
SafeCloseSocket socketHandle = _socketHandle;
if (socketHandle != null && !socketHandle.IsInvalid)
{
// We are being finalized while the I/O operation associated
// with the current overlapped is still pending (e.g. on app
// domain shutdown). The socket has to be closed first to
// avoid reuse after delete of the native overlapped structure.
socketHandle.Dispose();
}
// Release the native overlapped structure
return UnsafeNclNativeMethods.SafeNetHandles.LocalFree(handle) == IntPtr.Zero;
}
}