public async void CountdownEventAsyncShouldStopAwaitAllAwaitersWhenZeroReached() { _countdownEventAsync = new CountdownEventAsync(0); _countdownEventAsync.AddOnce(); var threadStarted = new TaskCompletionSource <bool>(); var completionSource = new TaskCompletionSource <bool>(); new Thread(o => { threadStarted.SetResult(true); _countdownEventAsync.WaitAsync().Wait(); completionSource.SetResult(true); }).Start(); await threadStarted.Task; StopAwaitInThread(); await _countdownEventAsync; Assert.True(_isStopped); _isStopped = await completionSource.Task; Assert.True(_isStopped); }
public void SetUp() { _countdownEventAsync = new CountdownEventAsync(5); }