Exemplo n.º 1
0
        public void CheckCountOfActiveThreads()
        {
            const int numOfThreads = 100;
            var       threadPool   = new MyThreadPool(numOfThreads);

            Assert.AreEqual(numOfThreads, threadPool.GetCountOfActiveThreads());

            const int numOfTasks = 100;

            for (int i = 0; i < numOfTasks; i++)
            {
                threadPool.AddTask(() => 1);
            }

            Assert.AreEqual(numOfThreads, threadPool.GetCountOfActiveThreads());

            threadPool.Shutdown();
            Assert.AreEqual(0, threadPool.GetCountOfActiveThreads());
        }