17 using System.Diagnostics;
18 using System.Threading;
28 private bool _stopped;
29 private Thread _thread;
30 private TimeSpan _period;
31 private Action<DateTime> _callback =
null;
32 private Stopwatch _timer =
new Stopwatch();
33 private DateTime _triggerTime;
41 _period = TimeSpan.FromSeconds(0);
42 _thread =
new Thread(
Scanner) { IsBackground =
true };
55 _timer =
new Stopwatch();
56 _thread =
new Thread(
Scanner) { IsBackground =
true };
58 _triggerTime = DateTime.UtcNow.RoundUp(period);
68 _triggerTime = DateTime.UtcNow.RoundDown(_period).Add(_period);
78 if (_callback !=
null && DateTime.UtcNow >= _triggerTime)
81 var triggeredAt = _triggerTime;
82 _triggerTime = DateTime.UtcNow.RoundDown(_period).Add(_period);
83 _callback(triggeredAt);
86 while (_paused && !_stopped) Thread.Sleep(10);