示例#1
0
        internal override async Task <bool> InitiateCleanClose(bool initiatedByServer, AmqpError error)
        {
            if (!initiatedByServer)
            {
                _conn.NotifyClosedByUser();

                while (!_commandOutbox.IsEmpty && !_socketHolder.IsClosed)
                {
                    // give it some time to finish writing to the socket (if it's open)
                    Thread.Sleep(250);
                }
            }
            else
            {
                if (_conn.NotifyClosedByServer() == RecoveryAction.WillReconnect)
                {
                    CancelPendingCommands(error);

                    return(false);
                }
            }

            _conn.CloseAllChannels(initiatedByServer, error);

            await base.InitiateCleanClose(initiatedByServer, error).ConfigureAwait(false);

            CancelPendingCommands(error);

            _socketHolder.Close();

            return(true);
        }
        internal override async Task <bool> InitiateCleanClose(bool initiatedByServer, AmqpError error)
        {
            if (!initiatedByServer)
            {
                while (true)
                {
                    if (_socketHolder.StillSending)
                    {
                        Thread.Sleep(1000);                         // give it some time to finish writing to the socket (if it's open)
                    }
                    break;
                }
            }

            _conn.CloseAllChannels(initiatedByServer, error);

            await base.InitiateCleanClose(initiatedByServer, error);

            CancelPendingCommands(error);

            _socketHolder.Close();

            return(true);
        }