private void WorkerThreadLoop() { // Mark the ThreadLocal to tell this is a worker isWorkedThread = true; try { do { while (TryCooperate()) { } semaphore.Wait(); if (disposing > 0) { return; } } while (true); } finally { if (disposing == 0) { // If this thread is aborted or errored, spin up a new thread prior to stopping CreateWorkerThread(); } else { Interlocked.Decrement(ref leftToDispose); } } }
private void WorkerThreadScope() { isWorkedThread = true; try { do { while (TryCooperate()) { } if (disposing > 0) { return; } semaphore.Wait(); } while (true); } finally { if (disposing == 0) { NewWorker(); } else { Interlocked.Decrement(ref leftToDispose); } } }
private void WorkerThreadScope() { isWorkedThread = true; try { do { while (TryCooperate()) { } semaphore.Wait(); } while (true); } finally { NewWorker(); } }