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(); }
public void When_canceling_existing_running_repeaters_by_scheduling_the_cancellation_ahead_of_time_Then_their_future_actions_should_not_be_invoked() { // Prepare, set up actions to be fired IActionScheduler scheduler = new DedicatedThreadScheduler(Sys); var cancelableOdd = new Cancelable(scheduler); scheduler.ScheduleRepeatedly(1, 150, () => TestActor.Tell("Test"), cancelableOdd); cancelableOdd.CancelAfter(50); //Expect one message ExpectMsg("Test"); //Validate that no messages were sent ExpectNoMsg(200); }
public void When_canceling_existing_running_repeaters_by_scheduling_the_cancellation_ahead_of_time_Then_their_future_actions_should_not_be_invoked() { // Prepare, set up actions to be fired IScheduler scheduler = new TaskBasedScheduler(); var cancelableOdd = new Cancelable(scheduler); scheduler.ScheduleTellRepeatedly(1, 150, TestActor, "Test", ActorRefs.NoSender, cancelableOdd); cancelableOdd.CancelAfter(50); //Expect one message ExpectMsg("Test"); //Validate that no messages were sent ExpectNoMsg(200); }
public void When_canceling_existing_running_repeaters_by_scheduling_the_cancellation_ahead_of_time_Then_their_future_actions_should_not_be_invoked() { // Prepare, set up actions to be fired IActionScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { var cancelableOdd = new Cancelable(scheduler); scheduler.ScheduleRepeatedly(1, 150, () => TestActor.Tell("Test"), cancelableOdd); cancelableOdd.CancelAfter(50); //Expect one message ExpectMsg("Test"); //Validate that no messages were sent ExpectNoMsg(200); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }