public async Task SignalAndWaitFromTwo()
        {
            var evt = new AsyncCountdownEvent(2);

            var first = evt.SignalAndWaitAsync();

            Assert.False(first.IsCompleted);

            var second = evt.SignalAndWaitAsync();
            await Task.WhenAll(first, second);
        }
        public void SignalAndWaitSynchronousBlockDoesNotHang()
        {
            SynchronizationContext.SetSynchronizationContext(SingleThreadedSynchronizationContext.New());
            var evt = new AsyncCountdownEvent(1);

            Assert.True(evt.SignalAndWaitAsync().Wait(AsyncDelay), "Hang");
        }
        public void SignalAndWaitAsyncReturnsFaultedTaskOnError()
        {
            var evt    = new AsyncCountdownEvent(0);
            var result = evt.SignalAndWaitAsync();

            Assert.True(result.IsFaulted);
            Assert.IsType(typeof(InvalidOperationException), result.Exception.InnerException);
        }
 public async Task SignalAndWaitFromOne()
 {
     var evt = new AsyncCountdownEvent(1);
     await evt.SignalAndWaitAsync();
 }