Exemple #1
0
        protected override bool ReleaseHandle()
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print(
                    "SafeCloseSocket#" + LoggingHash.HashString(this) + "::ReleaseHandle() m_InnerSocket=" +
                    _innerSocket == null ? "null" : LoggingHash.HashString(_innerSocket));
            }

            _released = true;
            InnerSafeCloseSocket innerSocket = _innerSocket == null ? null : Interlocked.Exchange <InnerSafeCloseSocket>(ref _innerSocket, null);

            if (innerSocket != null)
            {
#if DEBUG
                // On AppDomain unload we may still have pending Overlapped operations.
                // ThreadPoolBoundHandle should handle this scenario by canceling them.
                innerSocket.LogRemainingOperations();
#endif

                innerSocket.DangerousRelease();
            }

            InnerReleaseHandle();

            return(true);
        }
        protected override bool ReleaseHandle()
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"_innerSocket={_innerSocket}");
            }

            _released = true;
            InnerSafeCloseSocket innerSocket = _innerSocket == null ? null : Interlocked.Exchange <InnerSafeCloseSocket>(ref _innerSocket, null);

            if (innerSocket != null)
            {
#if DEBUG
                // On AppDomain unload we may still have pending Overlapped operations.
                // ThreadPoolBoundHandle should handle this scenario by canceling them.
                innerSocket.LogRemainingOperations();
#endif

                innerSocket.DangerousRelease();
            }

            InnerReleaseHandle();

            return(true);
        }