Esempio n. 1
0
        public void MultiThreadsScenario()
        {
            const int iterations  = 50;
            const int threadCount = 50;

            var pool = new ThirdPartyPool(10, 50);

            MultiThreadsScenario(threadCount, iterations, pool);
            Thread.Sleep(100);
            pool.WaitAll();
            Assert.GreaterOrEqual(threadCount, pool.TotalCount);
            Debug.WriteLine(pool.TotalCount);
        }
Esempio n. 2
0
        public void MaxCapacity()
        {
            const int capacity0  = 1;
            const int capacity1  = 25;
            const int iterations = 100;
            const int taskCount  = 25;

            var pool0 = new ThirdPartyPool(capacity0, capacity0);
            var sw    = Stopwatch.StartNew();

            MultiThreadsScenario(taskCount, iterations, pool0);
            pool0.WaitAll();
            Debug.WriteLine(sw.Elapsed);
            Assert.AreEqual(capacity0, pool0.TotalCount);

            var pool1 = new ThirdPartyPool(capacity1, capacity1);

            sw.Restart();
            MultiThreadsScenario(taskCount, iterations, pool1);
            pool1.WaitAll();
            Debug.WriteLine(sw.Elapsed);
            Assert.AreEqual(capacity1, pool1.TotalCount);
        }