public SingleThreadPriorityAsyncStarter(int maxFlow, int queuesCount)
 {
     _maxFlow = maxFlow;
     //_queuesCount = queuesCount;
     _flowCounter            = new WaitableCounter();
     _asyncActionQueueWorker = new SingleThreadedRelayMultiQueueWorker <Action>(a => a(), queuesCount);
 }
Example #2
0
        public QueueBackWorker(Action <TItem> actionInBackThread)
        {
            _items = new ConcurrentQueue <TItem>();
            _actionInBackThread = actionInBackThread;

            _counter = new WaitableCounter();             // свой счетчик с методами ожидания

            _workThread = new BackgroundWorker {
                WorkerReportsProgress = true
            };
            _workThread.DoWork += WorkingThreadStart;
            _workThread.RunWorkerAsync();
            _workThread.ProgressChanged += (sender, args) => ((Action)args.UserState).Invoke();              // если вылетает исключение - то оно будет в потоке GUI
        }
        public SingleThreadedRelayQueueWorker(Action <TItem> action, ThreadPriority threadPriority, bool markThreadAsBackground, ApartmentState?apartmentState)
        {
            _items  = new ConcurrentQueue <TItem>();
            _action = action;

            _counter = new WaitableCounter();             // свой счетчик с методами ожидания

            _workThread = new Thread(WorkingThreadStart)
            {
                IsBackground = markThreadAsBackground, Priority = threadPriority
            };
            if (apartmentState.HasValue)
            {
                _workThread.SetApartmentState(apartmentState.Value);
            }
            _workThread.Start();
        }
 public SingleThreadAsyncStarterWithFlowControl(int maxFlow, ThreadPriority threadPriority, bool markThreadAsBackground, ApartmentState?apartmentState)
 {
     _maxFlow                = maxFlow;
     _flowCounter            = new WaitableCounter();
     _asyncActionQueueWorker = new SingleThreadedRelayQueueWorker <Action>(a => a(), threadPriority, markThreadAsBackground, apartmentState);
 }