public void STPAndWIGStartSuspended()
        {
            STPStartInfo stpStartInfo = new STPStartInfo
            {
                StartSuspended = true
            };

            STP stp = new STP(stpStartInfo);

            WIGStartInfo wigStartInfo = new WIGStartInfo
            {
                StartSuspended = true
            };

            IWorkItemsGroup wig = stp.CreateWorkItemsGroup(10, wigStartInfo);

            wig.QueueWorkItem(new WorkItemCallback(this.DoWork));

            Assert.IsFalse(wig.WaitForIdle(200));

            wig.Start();

            Assert.IsFalse(wig.WaitForIdle(200));

            stp.Start();

            Assert.IsTrue(wig.WaitForIdle(5000), "WIG is not idle");
            Assert.IsTrue(stp.WaitForIdle(5000), "STP is not idle");
        }
        public void StartSuspended()
        {
            STPStartInfo stpStartInfo = new STPStartInfo
            {
                StartSuspended = true
            };

            STP stp = new STP(stpStartInfo);

            stp.QueueWorkItem(new WorkItemCallback(this.DoWork));

            Assert.IsFalse(stp.WaitForIdle(200));

            stp.Start();

            Assert.IsTrue(stp.WaitForIdle(200));
        }
        private static void CheckIsBackground(bool isBackground)
        {
            STPStartInfo stpStartInfo = new STPStartInfo
            {
                AreThreadsBackground = isBackground
            };

            STP stp = new STP(stpStartInfo);

            IWorkItemResult <bool> wir = stp.QueueWorkItem(() => GetCurrentThreadIsBackground());

            bool resultIsBackground = wir.GetResult();

            stp.WaitForIdle();

            Assert.AreEqual(isBackground, resultIsBackground);
        }
Esempio n. 4
0
        private void Concurrency(
            int concurrencyPerWig,
            int wigsCount,
            int workItemsCount)
        {
            Console.WriteLine(
                "Testing : concurrencyPerWig = {0}, wigsCount = {1}, workItemsCount = {2}",
                concurrencyPerWig,
                wigsCount,
                workItemsCount);

            _success           = true;
            _concurrencyPerWig = concurrencyPerWig;
            _randGen           = new Random(0);

            STPStartInfo stpStartInfo = new STPStartInfo
            {
                StartSuspended = true
            };

            STP stp = new STP(stpStartInfo);

            _concurrentOps = new int[wigsCount];

            IWorkItemsGroup[] wigs = new IWorkItemsGroup[wigsCount];

            for (int i = 0; i < wigs.Length; ++i)
            {
                wigs[i] = stp.CreateWorkItemsGroup(_concurrencyPerWig);
                for (int j = 0; j < workItemsCount; ++j)
                {
                    wigs[i].QueueWorkItem(new WorkItemCallback(this.DoWork), i);
                }

                wigs[i].Start();
            }

            stp.Start();

            stp.WaitForIdle();

            Assert.IsTrue(_success);

            stp.Shutdown();
        }
Esempio n. 5
0
 public void Fini()
 {
     _stp.WaitForIdle();
     _stp.Shutdown();
 }