Quote Originally Posted by jmcilhinney View Post
I wouldn't use a loop and Thread.Sleep at all. I would use a Timers.Timer, which raises its Elapsed event on a secondary thread by default. Given that there are only two tasks and their differing schedule, I would use two Timers. If there was only one schedule or a large number of tasks then I'd probably go for a single Timer and, in the latter case, use some logic to determine which task(s) to perform.

By the way, it is "pseudo", not "sudo".
Thanks! thats interesting, I never really thought of that.

Would you still choose this route if:

The initial thread will only exit when one of the task's determines it can at which point the two timers would stop and the task would continue.

Use a AutoResetEvent that is set by the task?

VB Code:
  1. 'Set up timer for task one and timer for task 2
  2.  
  3. Resetevent.WaitOne()
  4.  
  5. 'Stop Timers and clean up