示例#1
0
 public bool DirectSendOrEnqueue(Message message)
 {
     lock (this)
     {
         mailbox.Enqueue(message);
         IncrementInFlightCount();
         return(Interlocked.CompareExchange(ref isInSending, ActiveSentinel, NoneSentinel) == NoneSentinel);
     }
 }
        public void Open()
        {
            ConcurrentQueue <object> enqueuedMessages;

            lock (_lock)
            {
                _isOpen           = true;
                enqueuedMessages  = _enqueuedMessages;
                _enqueuedMessages = new ConcurrentQueue <object>();

                foreach (var m in enqueuedMessages)
                {
                    var envelope = m as Envelope;
                    if (envelope != null)
                    {
                        _mailbox.Enqueue(envelope);
                    }
                    else
                    {
                        _mailbox.EnqueueSystemMessage((SystemMessageEnvelope)m);
                    }
                }
            }
        }