public void ResetWaitForConsumers()
 {
     CountdownLatch countdown = new CountdownLatch(0);
     bool result = countdown.WaitOne();
     Assert.IsTrue(result);
     countdown.Reset(5);
     result = countdown.WaitOne(TimeSpan.FromMilliseconds(5));
     Assert.IsFalse(result);
     for (int i = 0; i < 5; i++)
     {
         ThreadPool.QueueUserWorkItem(delegate
         {
             countdown.Set();
         });
     }
     result = countdown.WaitOne();
     Assert.IsTrue(result);
 }
Пример #2
0
        public void ResetWaitForConsumers() {
            TestTool.RunTasks(ThreadCount,
                              () => {
                                  var countdown = new CountdownLatch(0);
                                  var result = countdown.WaitOne();
                                  Assert.IsTrue(result);

                                  countdown.Reset(5);
                                  result = countdown.WaitOne(TimeSpan.FromMilliseconds(5));
                                  Assert.IsFalse(result);

                                  for(var i = 0; i < 5; i++) {
                                      ThreadPool.QueueUserWorkItem(state => countdown.Set());
                                  }
                                  result = countdown.WaitOne();
                                  Assert.IsTrue(result);
                              });
        }
Пример #3
0
        public void ResetWaitForConsumers()
        {
            CountdownLatch countdown = new CountdownLatch(0);
            bool           result    = countdown.WaitOne();

            Assert.IsTrue(result);
            countdown.Reset(5);
            result = countdown.WaitOne(TimeSpan.FromMilliseconds(5));
            Assert.IsFalse(result);
            for (int i = 0; i < 5; i++)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    countdown.Set();
                });
            }
            result = countdown.WaitOne();
            Assert.IsTrue(result);
        }