public void TestAllTasksComplete() { ThreadPoolExecutor executor = new ThreadPoolExecutor(); Assert.IsNotNull(executor); Assert.IsFalse(executor.IsShutdown); for(int i = 0; i < JOB_COUNT; ++i) { executor.QueueUserWorkItem(TaskThatCountsDown); } Assert.IsTrue(this.doneLatch.await(TimeSpan.FromMilliseconds(30 * 1000))); executor.Shutdown(); Assert.IsTrue(executor.IsShutdown); }
public void TestThatShutdownPurgesTasks() { ThreadPoolExecutor executor = new ThreadPoolExecutor(); Assert.IsNotNull(executor); Assert.IsFalse(executor.IsShutdown); executor.QueueUserWorkItem(TaskThatSleeps); for(int i = 0; i < JOB_COUNT; ++i) { executor.QueueUserWorkItem(TaskThatIncrementsCount); } Thread.Sleep(100); executor.Shutdown(); Assert.AreEqual(0, count); Assert.IsTrue(executor.IsShutdown); }
public void TestTaskParamIsPropagated() { ThreadPoolExecutor executor = new ThreadPoolExecutor(); Assert.IsNotNull(executor); Assert.IsFalse(executor.IsShutdown); executor.QueueUserWorkItem(TaskThatValidatesTheArg, new DummyClass(10)); this.complete.WaitOne(); Assert.IsTrue(this.waitingTaskCompleted); executor.Shutdown(); Assert.IsTrue(executor.IsShutdown); }
public void TestSingleTaskExecuted() { ThreadPoolExecutor executor = new ThreadPoolExecutor(); Assert.IsNotNull(executor); Assert.IsFalse(executor.IsShutdown); executor.QueueUserWorkItem(TaskThatSignalsWhenItsComplete); this.complete.WaitOne(); Assert.IsTrue(this.waitingTaskCompleted); executor.Shutdown(); Assert.IsTrue(executor.IsShutdown); }