/// <summary>Notifies the ThreadPool that there's a new item to be executed.</summary>
 private void NotifyNewWorkItem()
 {
     ThreadPool.UnsafeQueueUserWorkItem(delegate(object _) {
         Task task = null;
         RoundRobinTaskSchedulerQueue queue = null;
         lock (this._queues)
         {
             foreach (int num in Enumerable.Range(this._nextQueue, this._queues.Count - this._nextQueue).Concat <int>(Enumerable.Range(0, this._nextQueue)))
             {
                 queue = this._queues[num];
                 Queue <Task> queue2 = queue._workItems;
                 if (queue2.Count > 0)
                 {
                     task            = queue2.Dequeue();
                     this._nextQueue = num;
                     if (queue._disposed && (queue2.Count == 0))
                     {
                         this.RemoveQueue_NeedsLock(queue);
                     }
                     break;
                 }
             }
             this._nextQueue = (this._nextQueue + 1) % this._queues.Count;
         }
         if (task != null)
         {
             queue.RunQueuedTask(task);
         }
     }, null);
 }
        /// <summary>Notifies the <see cref="ThreadPool"/> that there's a new item to be executed.</summary>
        private void NotifyNewWorkItem()
        {
            // Queue a processing delegate to the ThreadPool
            ThreadPool.UnsafeQueueUserWorkItem(_ =>
            {
                Task targetTask = null;
                RoundRobinTaskSchedulerQueue queueForTargetTask = null;
                lock (_queues)
                {
                    // Determine the order in which we'll search the schedulers for work
                    var searchOrder = Enumerable.Range(_nextQueue, _queues.Count - _nextQueue).Concat(Enumerable.Range(0, _nextQueue));

                    // Look for the next item to process
                    foreach (int i in searchOrder)
                    {
                        queueForTargetTask = _queues[i];
                        var items          = queueForTargetTask._workItems;
                        if (items.Count > 0)
                        {
                            targetTask = items.Dequeue();
                            _nextQueue = i;
                            if (queueForTargetTask._disposed && items.Count == 0)
                            {
                                RemoveQueue_NeedsLock(queueForTargetTask);
                            }
                            break;
                        }
                    }
                    _nextQueue = (_nextQueue + 1) % _queues.Count;
                }

                // If we found an item, run it
                if (targetTask != null)
                {
                    queueForTargetTask.RunQueuedTask(targetTask);
                }
            }, null);
        }