Release() 공개 메소드

public Release ( ) : void
리턴 void
예제 #1
0
        private void FreeNativeOverlapped()
        {
            IntPtr oldHandle = Interlocked.Exchange(ref handle, IntPtr.Zero);

            // Do not call free during AppDomain shutdown, there may be an outstanding operation.
            // Overlapped will take care calling free when the native callback completes.
            if (oldHandle != IntPtr.Zero && !Environment.HasShutdownStarted)
            {
                unsafe
                {
                    Debug.Assert(_safeCloseSocket != null, "m_SafeCloseSocket is null.");

                    ThreadPoolBoundHandle boundHandle = _safeCloseSocket.IOCPBoundHandle;
                    Debug.Assert(boundHandle != null, "SafeNativeOverlapped::ImmediatelyFreeNativeOverlapped - boundHandle is null");

                    if (boundHandle != null)
                    {
                        // FreeNativeOverlapped will be called even if boundHandle was previously disposed.
                        boundHandle.FreeNativeOverlapped((NativeOverlapped *)oldHandle);
                    }

#if DEBUG
                    _safeCloseSocket.Release();
#endif
                    _safeCloseSocket = null;
                }
            }
            return;
        }
예제 #2
0
        protected override bool ReleaseHandle()
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this);
            }

            FreeNativeOverlapped();

#if DEBUG
            _socketHandle.Release();
#endif
            return(true);
        }