public void Should_cancel_all_waiters() { var j = new AsyncJob <bool>(async cancellationToken => { await Task.Delay(10000, cancellationToken); return(true); }); var t1 = j.WaitAsync(); var t2 = j.WaitAsync(); j.Dispose(); t1.Status.Should().Be(TaskStatus.Canceled); t2.Status.Should().Be(TaskStatus.Canceled); }
/// <summary> /// Attempts to dispose of the job. /// </summary> /// <param name="value"></param> void TryDisposeJob(AsyncJob <bool> value) { try { value.Dispose(); } catch { // ignore } }