private void WorkingThreadStart()
        {
            try {
                while (true)
                {
                    // В этом цикле ждем пополнения очереди:
                    //_counter.WaitForIncrement();
                    _counter.WaitForCounterChangeWhileNotPredecate(count => count > 0);
                    while (true)
                    {
                        // в этом цикле опустошаем очередь
                        TItem dequeuedItem;
                        bool  shouldProceed = _items.TryDequeue(out dequeuedItem);
                        if (!shouldProceed)
                        {
                            break;
                        }

                        try {
                            _action(dequeuedItem);
                        }
                        catch {
                            continue;
                        }
                        finally {
                            _counter.DecrementCount();
                        }
                    }
                }
            }
            catch {
                //swallow all exeptions
            }
        }
        public void AddToQueueForExecution(Action asyncAction)
        {
            _asyncActionQueueWorker.AddToExecutionQueue(() => {
                _flowCounter.WaitForCounterChangeWhileNotPredecate(curCount => curCount < _maxFlow);

                _flowCounter.IncrementCount();
                asyncAction();
            });
        }
Esempio n. 3
0
 public void WaitForAnyCounterChangeWhileNotPredecate(Func <int, bool> predecate)
 {
     _totalCounter.WaitForCounterChangeWhileNotPredecate(predecate);
 }