title: How do I build a timer that executes some code in intervals?
body: <p>I have an application where it is possible for the user to schedule some taske. A task could be to "send email", "execute application" etc. Each of these tasks has a start time, and this varies. Some of these tasks should run from the start time of the task to the stat time of the next task.</p>
  
  <p>My question is how do i build a timer that will allow this to happen. Usually i would do this using a backgroundworker and an infinite loop - then check the time and the schedules each second or so. The problem with this approach is that when i close my application, the background worker is not closed.</p>
  
  <p>Any ideas on a better pattern for this timer, or for solving the thread issue?</p>