private void CustomTimerProc(object state) { // The state object is the Timer object. CustomTimer t = (CustomTimer)state; Console.WriteLine("The custom timer with interval " + t.GetInterval() + " callback finished"); t.Dispose(); }
public void StartCustomTimerAndStop() { CustomTimer t = new CustomTimer(new TimerCallback(CustomTimerProc)); t.Start(10); // wait 2 seconds and stop it Thread.Sleep(2000); t.Stop(); }
public void StartCustomTimer() { CustomTimer t = new CustomTimer(new TimerCallback(CustomTimerProc)); t.Start(10); }