コード例 #1
0
 public void ThreadingTimerZeroWait()
 {
     _t          = new ThreadingTimer(50);
     _t.Elapsed += TimerElapsed;
     _t.Start();
     Thread.Sleep(265);
     Assert.AreEqual(5, _elapsedCount);
 }
コード例 #2
0
 public void ThreadingTimerInitialization()
 {
     _t = new ThreadingTimer(15, 101);
     Assert.AreEqual(15, _t.Period);
     _t.Start();
     _t.Dispose();
     _t = new ThreadingTimer(15);
 }
コード例 #3
0
 public void ThreadingTimerNoOverlap()
 {
     _t          = new ThreadingTimer(50);
     _t.Elapsed += TimerElapsed100;
     _t.Start();
     Thread.Sleep(350);
     _t.Stop();
     Assert.IsTrue(_elapsedCount >= 2);
 }
コード例 #4
0
        static EventMetricsCleaner()
        {
            ReportEventCounts = new ReportEventCounts();
            ContextRegistries = new ContextRegistries();
            curInterval       = cleanIntervalBuffer;

            timer       = new ThreadingTimer(null, curInterval, curInterval);
            timer.Tick += (sender, args) => Clean();
        }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
        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);
        }