Ejemplo n.º 1
0
        public static void TestSemaphoreScheduler()
        {
            var test = new MyThreadingTestSuite();

            var scheduler = new SemaphoreScheduler(50);

            scheduler.TrySchedulingAndProcessing(10, test.GetLongRunningAction());

            Console.WriteLine("Main thread work done!");
        }
Ejemplo n.º 2
0
        public static void TestProducerConsumer()
        {
            var test      = new MyThreadingTestSuite();
            var processor = new Action <int>((i) => { Console.WriteLine("\t\t\tConsuming " + i); });
            var job       = new MyDummyProducerConsumer <int>(2, processor);
            var limit     = test.Random.Next(100);

            for (int i = 0; i < limit; i++)
            {
                job.Produce(test.Random.Next());
            }

            job.Produce(0);
            job.Produce(0);
        }