public void CancelAfter(TimeSpan delay) { if(delay < TimeSpan.Zero) throw new ArgumentOutOfRangeException("delay", "The delay must be >0, it was " + delay); InternalCancelAfter(delay); }
public void Should_be_possible_to_call_CancelAfterTimespan() { var c = new Cancelable(Sys.Scheduler); var latch = CreateTestLatch(); c.Token.Register(() => latch.CountDown()); c.CancelAfter(TimeSpan.FromMilliseconds(50)); c.IsCancellationRequested.ShouldBeFalse(); latch.Ready(); c.IsCancellationRequested.ShouldBeTrue(); c.Token.IsCancellationRequested.ShouldBeTrue(); }