// Handle expiry of the timer. private static void TimerExpired(Object state) { Timer timer = (Timer)state; if (!(timer.autoReset)) { timer.enabled = false; timer.timer = null; } if (timer.Elapsed != null) { timer.Elapsed(timer, new ElapsedEventArgs(DateTime.Now)); } }
static void Callback(object state) { Timer timer = (Timer)state; if (timer.Elapsed == null) { return; } ElapsedEventArgs arg = new ElapsedEventArgs(DateTime.Now); if (timer.so != null && timer.so.InvokeRequired) { timer.so.BeginInvoke(timer.Elapsed, new object[2] { timer, arg }); } else { timer.Elapsed(timer, arg); } }