Shutdown() public method

public Shutdown ( ) : void
return void
        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);
        }
Esempio n. 2
0
 public void TestConstructor()
 {
     ThreadPoolExecutor executor = new ThreadPoolExecutor();
     Assert.IsNotNull(executor);
     Assert.IsFalse(executor.IsShutdown);
     executor.Shutdown();
     Assert.IsTrue(executor.IsShutdown);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }