예제 #1
0
        public override void Dispose()
        {
            if (_isDisposed)
            {
                _logger.LogTrace("Queue {Name} ({Id})  dispose was already called.", _options.Name, QueueId);
                return;
            }

            _isDisposed = true;
            _logger.LogTrace("Queue {Name} ({Id}) dispose", _options.Name, QueueId);
            _queueDisposedCancellationTokenSource?.Cancel();
            _queueDisposedCancellationTokenSource?.Dispose();
            base.Dispose();

            Abandoned?.Dispose();
            Completed?.Dispose();
            Dequeued?.Dispose();
            Enqueued?.Dispose();
            Enqueuing?.Dispose();
            LockRenewed?.Dispose();

            foreach (var behavior in _behaviors.OfType <IDisposable>())
            {
                behavior.Dispose();
            }

            _behaviors.Clear();
        }
예제 #2
0
        public T Dequeue()
        {
            T item = queue.Dequeue();

            Dequeued?.Invoke(null, item);
            return(item);
        }
예제 #3
0
        /// <summary>
        /// The event which fires when the consumer receives a delivery
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="basicDeliverEventArgs">The <see cref="BasicDeliverEventArgs"/> instance containing the event data.</param>
        private void ConsumerOnReceived(object sender, BasicDeliverEventArgs basicDeliverEventArgs)
        {
            byte[] body = basicDeliverEventArgs.Body;

            T result = JsonConvert.DeserializeObject <T>(Encoding.UTF8.GetString(body), _jss);

            Dequeued?.Invoke(this, result);
        }
예제 #4
0
        /// <summary>
        /// Dequeues this instance.
        /// </summary>
        /// <returns></returns>
        public T Dequeue()
        {
            _backingQueue.TryDequeue(out T result);

            Dequeued?.Invoke(this, result);

            return(result);
        }
예제 #5
0
 private void OnDequeued(TResult item)
 {
     try
     {
         Dequeued?.Invoke(item);
     }
     catch (Exception ex)
     {
         _context.TraceSource.ContextSwitch_Dequeued_Error(ex);
     }
 }
예제 #6
0
        public virtual void Dequeue()
        {
            T item;

            while (!queue.IsEmpty)
            {
                if (!queue.TryDequeue(out item))
                {
                    continue;
                }
                Dequeued?.Invoke(this, new ItemEventArgs <T>(item));
                break;
            }
        }
예제 #7
0
파일: QueueBase.cs 프로젝트: nj/Foundatio
        public override void Dispose()
        {
            _logger.Trace("Queue {0} dispose", _queueName);
            base.Dispose();

            Abandoned?.Dispose();
            Completed?.Dispose();
            Dequeued?.Dispose();
            Enqueued?.Dispose();
            Enqueuing?.Dispose();
            LockRenewed?.Dispose();

            foreach (var behavior in _behaviors.OfType <IDisposable>())
            {
                behavior.Dispose();
            }

            _behaviors.Clear();
        }
예제 #8
0
        public override void Dispose()
        {
            _logger.LogTrace("Queue {0} dispose", _options.Name);
            _queueDisposedCancellationTokenSource?.Cancel();
            base.Dispose();

            Abandoned?.Dispose();
            Completed?.Dispose();
            Dequeued?.Dispose();
            Enqueued?.Dispose();
            Enqueuing?.Dispose();
            LockRenewed?.Dispose();

            foreach (var behavior in _behaviors.OfType <IDisposable>())
            {
                behavior.Dispose();
            }

            _behaviors.Clear();
        }
예제 #9
0
 protected virtual void OnDequeued()
 {
     Dequeued?.Invoke(this, new DequeueEventArgs(queue.Count));
 }
예제 #10
0
 public override void OnDequeue(MachineId machineId, string currentStateName, string eventName)
 {
     base.OnDequeue(machineId, currentStateName, eventName);
     Dequeued?.Invoke(machineId, currentStateName, eventName);
 }
예제 #11
0
 public void OnDequeued(object sender, PersonModel person, RoomModel room)
 {
     Dequeued?.Invoke(sender, new EnqueingEventArgs(person, room));
 }