public void Consuming()
        {
            while (true)
            {
                if (_queue.Count > 0)
                {
                    IThreads_Task task = _queue.Dequeue();
                    task.Do();
                }

                if (_bunch <= MAX_BUNCHES)
                {
                    _consumerPool.WaitOne();
                }
                else
                {
                    return;
                }
            }
        }
Exemplo n.º 2
0
        public void Consuming()
        {
            Console.WriteLine("Start Consuming");
            while (true)
            {
                lock (lockObject)
                {
                    if (_queue.Count <= 0)
                    {
                        if (_bunch >= MAX_BUNCHES)
                        {
                            return;
                        }

                        Monitor.Pulse(lockObject);
                        Monitor.Wait(lockObject);
                        continue;
                    }

                    IThreads_Task task = _queue.Dequeue();
                    task.Do();
                }
            }
        }