public void WaitAllWithTimeoutFailure()
        {
            STP             smartThreadPool = new STP();
            IWorkItemsGroup workItemsGroup  = smartThreadPool.CreateWorkItemsGroup(int.MaxValue);

            IWorkItemResult[] wirs = new IWorkItemResult[5];

            for (int i = 0; i < wirs.Length; ++i)
            {
                wirs[i] =
                    workItemsGroup.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();
            IWorkItemsGroup workItemsGroup  = smartThreadPool.CreateWorkItemsGroup(int.MaxValue);

            bool success = true;

            IWorkItemResult[] wirs = new IWorkItemResult[5];

            for (int i = 0; i < wirs.Length; ++i)
            {
                wirs[i] =
                    workItemsGroup.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);
        }