/// <summary>Queues a task to the scheduler.</summary>
 /// <param name="task">The task to be queued.</param>
 protected sealed override void QueueTask(tt.Task task)
 {
     // Add the task to the list of tasks to be processed.  If there aren't enough
     // delegates currently queued or running to process tasks, schedule another.
     lock (tasks)
     {
         tasks.AddLast(task);
         if (delegatesQueuedOrRunning < maxDegreeOfParallelism)
         {
             ++delegatesQueuedOrRunning;
             NotifyThreadPoolOfPendingWork();
         }
     }
 }
 protected TaskWrapper( _THREADING.Task t )
 {
     Debug.Assert( t != null );
     _t = t;
 }
        /// <summary>Attempts to execute the specified task on the current thread.</summary>
        /// <param name="task">The task to be executed.</param>
        /// <param name="taskWasPreviouslyQueued"></param>
        /// <returns>Whether the task could be executed on the current thread.</returns>
        protected sealed override bool TryExecuteTaskInline(tt.Task task, bool taskWasPreviouslyQueued)
        {
            // If this thread isn't already processing a task, we don't support inlining
            if (!currentThreadIsProcessingItems) return false;

            // If the task was previously queued, remove it from the queue
            if (taskWasPreviouslyQueued) TryDequeue(task);

            // Try to run the task.
            return base.TryExecuteTask(task);
        }
 /// <summary>Attempts to remove a previously scheduled task from the scheduler.</summary>
 /// <param name="task">The task to be removed.</param>
 /// <returns>Whether the task could be found and removed.</returns>
 protected sealed override bool TryDequeue(tt.Task task)
 {
     lock (tasks) return tasks.Remove(task);
 }