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); }
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); }); }