Esempio n. 1
0
        private bool TrySetShutdown(PipeShutdownKind kind, SocketError socketError)
        {
            var win = TrySetShutdown(kind);

            if (win)
            {
                SocketError = socketError;
            }

            return(win);
        }
Esempio n. 2
0
        /// <summary>
        /// Try to signal the pipe shutdown reason as being due to an application protocol event
        /// </summary>
        /// <param name="kind">The kind of shutdown; only protocol-related reasons will succeed</param>
        /// <returns>True if successful</returns>
        public bool TrySetProtocolShutdown(PipeShutdownKind kind)
        {
            switch (kind)
            {
            case PipeShutdownKind.ProtocolExitClient:
            case PipeShutdownKind.ProtocolExitServer:
                return(TrySetShutdown(kind));

            default:
                return(false);
            }
        }
Esempio n. 3
0
 private bool TrySetShutdown(Exception ex, PipeShutdownKind kind)
 {
     try
     {
         return(ex is SocketException se?
                TrySetShutdown(kind, se.SocketErrorCode) : TrySetShutdown(kind));
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
0
 private bool TrySetShutdown(PipeShutdownKind kind)
 {
     return(kind != PipeShutdownKind.None &&
            Interlocked.CompareExchange(ref _socketShutdownKind, (int)kind, 0) == 0);
 }