Exemple #1
0
        private PriorityTaskPool(int executorsCount)
        {
            for (var i = 0; i < executorsCount; i++)
            {
                var executor = new TaskExecutor(this);
                _executors.Add(executor);
            }

            Console.CancelKeyPress += delegate
            {
                if (State == TaskPoolState.Started)
                {
                    Stop();
                }
            };
        }
Exemple #2
0
 public ITask GetNextTask(TaskExecutor executor)
 {
     lock (_lock)
     {
         var task = _tasks.Dequeue();
         if (task == null) Monitor.Wait(_lock);
         return task;
     }
 }