public void Stop() { _active = false; _timerProc = null; if (_thread != null) { _thread.Join(); _thread = null; } }
public ThreadTimer(int interval, ThreadTimerProc timerProc, int startDelay) { _interval = interval; _timerProc = timerProc; _active = true; _thread = new Thread(() => { SafeSleep(startDelay); while (_active) { if (_timerProc != null) _timerProc(); SafeSleep(_interval); } }); _thread.Start(); }
public ThreadTimer(int interval, ThreadTimerProc timerProc) : this(interval, timerProc, 0) { }