Пример #1
0
        public void Stop()
        {
            _active = false;
            _timerProc = null;

            if (_thread != null)
            {
                _thread.Join();
                _thread = null;
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
 public ThreadTimer(int interval, ThreadTimerProc timerProc)
     : this(interval, timerProc, 0)
 {
 }