public void Cancel() { int executionCount = 0; Action action = () => executionCount++; var timer = new TimerAction(StubFiber.StartNew(), action, TimeSpan.FromMilliseconds(2)); Thread.Sleep(100); Assert.AreEqual(1, executionCount); timer.Dispose(); Thread.Sleep(150); Assert.AreEqual(1, executionCount); }
public void Cancel() { var executionCount = 0; Action action = () => executionCount++; var timer = new TimerAction(action, 1, 2); timer.ExecuteOnFiberThread(); Assert.AreEqual(1, executionCount); timer.Dispose(); timer.ExecuteOnFiberThread(); Assert.AreEqual(1, executionCount); }
public void CallbackFromIntervalTimerWithCancel() { var mocks = new MockRepository(); var action = mocks.CreateMock <Action>(); var timer = new TimerAction(action, 2, 3); var registry = mocks.CreateMock <ISchedulerRegistry>(); registry.Remove(timer); mocks.ReplayAll(); timer.Dispose(); timer.ExecuteOnTimerThread(registry); }
public void Cancel() { int executionCount = 0; void Action() { executionCount++; } TimerAction timer = new TimerAction(new StubFiber(), Action, TimeSpan.FromMilliseconds(2)); Thread.Sleep(100); Assert.AreEqual(1, executionCount); timer.Dispose(); Thread.Sleep(150); Assert.AreEqual(1, executionCount); }
public void CallbackFromIntervalTimerWithCancel() { int executionCount = 0; Action action = () => executionCount++; using (IFiber stubFiber = StubFiber.StartNew()) { var timer = new TimerAction(stubFiber, action, TimeSpan.FromMilliseconds(2), TimeSpan.FromMilliseconds(150)); Thread.Sleep(100); Assert.AreEqual(1, executionCount); timer.Dispose(); Thread.Sleep(150); Assert.AreEqual(1, executionCount); } }
public void CallbackFromIntervalTimerWithCancel() { int executionCount = 0; void Action() { executionCount++; } using (StubFiber stubFiber = new StubFiber()) { TimerAction timer = new TimerAction(stubFiber, Action, TimeSpan.FromMilliseconds(2), TimeSpan.FromMilliseconds(150)); Thread.Sleep(100); Assert.AreEqual(1, executionCount); timer.Dispose(); Thread.Sleep(150); Assert.AreEqual(1, executionCount); } }