Exemplo n.º 1
0
 public void TestSlotTimer()
 {
     var timer = new Timer();
     var startTime = DateTimeProvider.Now;
     var count = 0;
     timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
     timer.Tick += () =>
         {
             var timespan = (DateTimeProvider.Now - startTime);
             Assert.IsTrue(Math.Abs((timespan - timer.Interval).TotalMilliseconds) < 50);
             startTime = DateTimeProvider.Now;
             ++count;
             if (count == 3)
             {
                 timer.Stop();
                 SimpleDispatcher.CurrentDispatcher.Shutdown();
             }
         };
     timer.Start();
     SimpleDispatcher.CurrentDispatcher.Run();
     Assert.AreEqual(3, count);
 }
Exemplo n.º 2
0
 public TimeSpanWaiter(TimeSpan span)
 {
     timer = new Timer(span, this.OnCompleted);
     timer.Start();
 }