public ATimer(int timerType, int intervalMS, ElapsedTimerDelegate callback) { _timerType = timerType; _interval = intervalMS; _elapsedTimerHandler = callback; if (timerType == 0) { _elapsedTimer0Handler = Timer0Handler; } else if (timerType == 1) { _elapsedTimer1Handler = Timer1Handler; _timer1 = new System.Windows.Forms.Timer(); _timer1.Interval = _interval; _timer1.Tick += Timer1Handler; } else if (timerType == 2) { _timer2 = new MicroTimer(); _timer2.Interval = _interval * 1000; _timer2.MicroTimerElapsed += Timer2Handler; } else if (timerType == 3) { } }
/// <summary> /// Initlaizes a FastTimer object /// </summary> /// <param name="timerType">0 = System.Threading (default), 1 = Windows.Forms, 3 = Multimedia timer (windows mm dll)</param> /// <param name="intervalMS">Time interval between calls</param> /// <param name="callback">Method to be called each time intervalMS elapses</param> public FastTimer(int timerType, int intervalMS, ElapsedTimerDelegate callback) { _timerType = timerType; _interval = intervalMS; _elapsedTimerHandler = callback; switch (timerType) { case 0: _elapsedTimer0Handler = Timer0Handler; break; case 1: _elapsedTimer1Handler = Timer1Handler; _timer1 = new System.Windows.Forms.Timer(); _timer1.Interval = _interval; _timer1.Tick += Timer1Handler; break; case 3: break; default: throw (new NotImplementedException()); } }