public void TestMethodOneTask()
        {
            ThreadPool.ThreadPool threadPool = new ThreadPool.ThreadPool(new Random(), 4);
            MyTask <String>       task       = new MyTask <String>(() => "Hello");

            threadPool.Enqueue(task);
            threadPool.Start();
            Thread.Sleep(1000);
            threadPool.Dispose();
            Assert.AreEqual("Hello", task.Result());
        }
        public void TestMethodContinueWith()
        {
            ThreadPool.ThreadPool threadPool = new ThreadPool.ThreadPool(new Random(), 4);
            var task1 = new MyTask <int>(() => 2 + 2);
            var task2 = task1.ContinueWith(y => y + 1);
            var task3 = task2.ContinueWith(y => y * 2);

            threadPool.Enqueue(task1);
            threadPool.Enqueue(task2);
            threadPool.Enqueue(task3);
            threadPool.Start();
            Thread.Sleep(1000);
            threadPool.Dispose();
            Assert.AreEqual(4, task1.Result());
            Assert.AreEqual(5, task2.Result());
            Assert.AreEqual(10, task3.Result());
        }
        public void TestMethodSomeTask()
        {
            ThreadPool.ThreadPool threadPool = new ThreadPool.ThreadPool(new Random(), 4);
            MyTask <int>          task1      = new MyTask <int>(() => 2 + 2);
            MyTask <int>          task2      = new MyTask <int>(() => { int x = 0; return(1 / x); });
            MyTask <String>       task3      = new MyTask <String>(() => "Task3");

            threadPool.Enqueue(task1);
            threadPool.Enqueue(task2);
            threadPool.Enqueue(task3);
            threadPool.Start();
            Thread.Sleep(1000);
            threadPool.Dispose();
            Assert.AreEqual(4, task1.Result());
            Assert.ThrowsException <AggregateException>(() => task2.Execute());
            Assert.AreEqual("Task3", task3.Result());
        }