public void TestFreezableClockAsync() { var et = 0; var clock = new FreezableClock(AlignedClock.FromNow(Clocks.SystemTicksClock.As(TimeUnit.Millisecond))); Task.Delay(3000).ContinueWith(task => { clock.Freeze(); Thread.Sleep(1000); clock.Unfreeze(); }); Thread.Sleep(2000); et += 2000; var t = clock.Time; Debug.WriteLine($"t = {t}"); Assert.IsTrue(Math.Abs(et - t) < ToleranceInMillis); Thread.Sleep(5000); et += 4000; t = clock.Time; Debug.WriteLine($"t = {t}"); Assert.IsTrue(Math.Abs(et - t) < ToleranceInMillis); }
/// <summary> /// Stop program. /// </summary> /// <returns>Successfully stopped</returns> public bool Stop() { if (_cyclicExecutor.Stop(false)) { CurrentStage = null; FreezableClock.Unfreeze(); return(true); } return(false); }
/// <summary> /// Resume program. /// </summary> /// <returns>Successfully resumed</returns> public bool Resume() => FreezableClock.Unfreeze();