/// <summary>
 /// Adds async operations in queue
 /// </summary>
 /// <param name="asyncAction">Action that runs async</param>
 /// <param name="queueNumber">Queue priority</param>
 public void AddWork(Action asyncAction, int queueNumber)
 {
     _asyncActionQueueWorker.AddWork
     (
         () => {
         _flowCounter.WaitForCounterChangeWhileNotPredecate(curCount => curCount < _maxFlow);
         _flowCounter.IncrementCount();
         _debugLogger.Log("_flowCounter.Count = " + _flowCounter.Count, new StackTrace());
         asyncAction();
     },
         queueNumber
     );
 }
Ejemplo n.º 2
0
 public void AddWork(TItem workItem, int queueNumber)
 {
     lock (_syncUserActions) {
         lock (_syncRunFlags) {
             if (!_mustBeStopped)
             {
                 _items.Enqueue(workItem, queueNumber);
                 _threadNotifyAboutQueueItemsCountChanged.Set();
             }
             else
             {
                 var ex = new Exception("Cannot handle items any more, worker has been stopped or stopping now");
                 _debugLogger.Log(ex, new StackTrace());
                 throw ex;
             }
         }
     }
 }