static void Main() { var timer = new Timer { AutoReset = true, Interval = 1000 }; timer.Elapsed += (x, y) => taskInstance.DoWork(); cancelEvent.Wait(); }