So, here is an example for which timer users do the work suggested by Brian. Use start / stop if necessary. To clear an object (Program) as soon as you are done with it, make sure you call Dispose.
Just remember that when you call Stop, this will prevent the timer from starting again, however you can still have a worker thread in the middle of the timer_Elapsed handler, i.e. stopping the timer does not stop the execution of the current workflow.
using System; using System.Timers; namespace TimerApp { class Program : IDisposable { private Timer timer; public Program() { this.timer = new Timer(); this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); this.timer.AutoReset = true; this.timer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds; } void timer_Elapsed(object sender, ElapsedEventArgs e) {
source share