Example #1
0
 // Creates a new instance with the specified degree of parallelism.
 public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
 {
     if (maxDegreeOfParallelism < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism));
     }
     _maxDegreeOfParallelism = maxDegreeOfParallelism;
     this._taskCounters      = new TaskCounters();
 }
Example #2
0
        public bool Done()
        {
            // single get, it's locked inside the method
            Scheduler.RecalculateCounters();
            TaskCounters taskCounters = Scheduler.GetTaskCounters();

            if ((taskCounters.CurrentTasksQueued + taskCounters.CurrentTasksRunning == 0))
            {
                return(true);
            }

            return(false);
        }