コード例 #1
0
        private void Run()
        {
            ProcCommand command = null;

            try
            {
                while (true)
                {
                    _semaLock.Enter();

                    if (_commandsQueue.Count == 0)
                    {
                        lock (_queueLock)
                        {
                            _workerWaiting = true;
                            _semaLock.Exit();
                            Monitor.Wait(_queueLock);
                        }
                        _semaLock.Enter();
                        _workerWaiting = false;
                    }
                    command = _commandsQueue.Dequeue();
                    _semaLock.Exit();
                    _processor.Process(command);
                }
            }
            catch (Exception) {
                if (command != null && command.ClientManager != null)
                {
                    command.ClientManager.Dispose();
                }
            }
        }
コード例 #2
0
        public void EnqueuRequest(ProcCommand request)
        {
#if NET40
            _semaLock.Enter();

            _commandsQueue.Enqueue(request);

            if (_workerWaiting)
            {
                lock (_queueLock){
                    Monitor.Pulse(_queueLock);
                }
            }

            _semaLock.Exit();
#else
            lock (_queueLock)
            {
                _commandsQueue.Enqueue(request);
                if (_workerWaiting)
                {
                    Monitor.Pulse(_queueLock);
                }
            }
#endif
        }
コード例 #3
0
 public void EnqueuRequest(ProcCommand request, uint indexFeed)
 {
     _workers[indexFeed % _maxProcessors].EnqueuRequest(request);
 }