public void ThreadingTimerZeroWait() { _t = new ThreadingTimer(50); _t.Elapsed += TimerElapsed; _t.Start(); Thread.Sleep(265); Assert.AreEqual(5, _elapsedCount); }
public void ThreadingTimerInitialization() { _t = new ThreadingTimer(15, 101); Assert.AreEqual(15, _t.Period); _t.Start(); _t.Dispose(); _t = new ThreadingTimer(15); }
public void ThreadingTimerNoOverlap() { _t = new ThreadingTimer(50); _t.Elapsed += TimerElapsed100; _t.Start(); Thread.Sleep(350); _t.Stop(); Assert.IsTrue(_elapsedCount >= 2); }
static EventMetricsCleaner() { ReportEventCounts = new ReportEventCounts(); ContextRegistries = new ContextRegistries(); curInterval = cleanIntervalBuffer; timer = new ThreadingTimer(null, curInterval, curInterval); timer.Tick += (sender, args) => Clean(); }
public void ThreadingTimerDelayTimerStart() { _t = new ThreadingTimer(100, 100); _t.Elapsed += TimerElapsed; _t.Start(); Thread.Sleep(90); Assert.AreEqual(0, _elapsedCount); Thread.Sleep(220); Assert.AreEqual(2, _elapsedCount); }
public void ThreadingTimerRunGivenTimes() { _t = new ThreadingTimer(100, 10); _t.Elapsed += TimerElapsed; _t.Start(); Thread.Sleep(240); Assert.IsTrue(_t.Running); _t.Stop(); Assert.AreEqual(3, _elapsedCount); Assert.IsFalse(_t.Running); }
public void ThreadingTimerRemoveElapsed() { _t = new ThreadingTimer(1, 1); _t.Elapsed += TimerElapsed; _t.Start(100, 100); Thread.Sleep(90); Assert.AreEqual(0, _elapsedCount); Thread.Sleep(120); _t.Stop(); var elapsed = _elapsedCount; _t.Elapsed -= TimerElapsed; _t.Start(100, 100); Thread.Sleep(90); Assert.AreEqual(elapsed, _elapsedCount); Thread.Sleep(220); _t.Stop(); Assert.AreEqual(elapsed, _elapsedCount); Assert.AreNotEqual(_t.TimesRun, _elapsedCount); }