public void WaitAllT()
        {
            STP smartThreadPool = new STP();

            bool success = true;

            IWorkItemResult <int>[] wirs = new IWorkItemResult <int> [5];

            for (int i = 0; i < wirs.Length; ++i)
            {
                wirs[i] = smartThreadPool.QueueWorkItem(new Func <int, int, int>(System.Math.Min), i, i + 1);
            }

            STP.WaitAll(wirs);

            for (int i = 0; i < wirs.Length; ++i)
            {
                if (!wirs[i].IsCompleted)
                {
                    success = false;
                    break;
                }

                int result = wirs[i].GetResult();
                if (i != result)
                {
                    success = false;
                    break;
                }
            }

            smartThreadPool.Shutdown();

            Assert.IsTrue(success);
        }
        public void WaitAllWithEmptyArray()
        {
            IWorkItemResult[] wirs = new IWorkItemResult[0];

            bool success = STP.WaitAll(wirs);;

            Assert.IsTrue(success);
        }
        public void WaitAllWithTimeoutFailure()
        {
            STP smartThreadPool = new STP();

            IWorkItemResult[] wirs = new IWorkItemResult[5];

            for (int i = 0; i < wirs.Length; ++i)
            {
                wirs[i] =
                    smartThreadPool.QueueWorkItem(new WorkItemCallback(this.DoSomeWork), null);
            }

            bool timeout = !STP.WaitAll(wirs, 10, true);
            bool success = timeout;

            smartThreadPool.Shutdown();

            Assert.IsTrue(success);
        }
        public void WaitAll()
        {
            STP smartThreadPool = new STP();

            bool success = true;

            IWorkItemResult[] wirs = new IWorkItemResult[5];

            for (int i = 0; i < wirs.Length; ++i)
            {
                wirs[i] =
                    smartThreadPool.QueueWorkItem(new WorkItemCallback(this.DoSomeWork), null);
            }

            STP.WaitAll(wirs);

            for (int i = 0; i < wirs.Length; ++i)
            {
                if (!wirs[i].IsCompleted)
                {
                    success = false;
                    break;
                }
                else
                {
                    int result = (int)wirs[i].GetResult();
                    if (1 != result)
                    {
                        success = false;
                        break;
                    }
                }
            }

            smartThreadPool.Shutdown();

            Assert.IsTrue(success);
        }