public void Dispatch() { RevaleeTask task; while ((task = Supervisor.State.DoleTask()) != null) { for (int retryCount = 0; retryCount <= 4; retryCount++) { if (AbortableThreadPool.QueueUserWorkItem(new WaitCallback(ProcessTask), task)) { // Clear any previous failures _ConsecutiveDoleFailures = 0; // Worker thread successful, no intervals needed break; } if (retryCount < 4) { Thread.Sleep(50); } else { // Increment the overload counter Interlocked.Increment(ref _ConsecutiveDoleFailures); // Add the task back to the state manager Supervisor.State.ReenlistTask(task); } } } }
public void Halt() { AbortableThreadPool.ForceClose(); }