public async Task TimedOut() { var a = new AsyncManualResetEventEx(); var sw = Stopwatch.StartNew(); bool success = await a.WaitAsync(1000); sw.Stop(); Assert.InRange(sw.ElapsedMilliseconds, 1000, 10_000); Assert.False(success); }
public async Task Release() { var a = new AsyncManualResetEventEx(); _ = Task.Delay(2000).ContinueWith(_ => a.Set()); var sw = Stopwatch.StartNew(); await a.WaitAsync(); sw.Stop(); Assert.InRange(sw.ElapsedMilliseconds, 2000, 10_000); }
public async Task NotTimedOut() { var a = new AsyncManualResetEventEx(); _ = Task.Delay(500).ContinueWith(_ => a.Set()); var sw = Stopwatch.StartNew(); bool success = await a.WaitAsync(1000); sw.Stop(); Assert.InRange(sw.ElapsedMilliseconds, 500, 2000); Assert.True(success); }
public async Task DelayedCancelTimedOut() { var a = new AsyncManualResetEventEx(); using var cts = new CancellationTokenSource(1000); var sw = Stopwatch.StartNew(); bool success = await a.WaitAsync(500, cts.Token); sw.Stop(); Assert.InRange(sw.ElapsedMilliseconds, 500, 2000); Assert.False(success); }
public async Task DelayedCancelWithTimeout() { var a = new AsyncManualResetEventEx(); using var cts = new CancellationTokenSource(1000); var sw = Stopwatch.StartNew(); try { await a.WaitAsync(10_000, cts.Token); } catch (OperationCanceledException) { sw.Stop(); Assert.InRange(sw.ElapsedMilliseconds, 1000, 10_000); return; } Assert.True(false); }
public DebugView(AsyncManualResetEventEx mre) { _mre = mre; }