What is the best way to implement a “timer”? [duplicate]

What is the best way to implement a timer? A code sample would be great! For this question, “best” is defined as most reliable (least number of misfires) and precise. If I specify an interval of 15 seconds, I want the target method invoked every 15 seconds, not every 10 – 20 seconds. On the other hand, I don’t need nanosecond accuracy. In this example, it would be acceptable for the method to fire every 14.51 – 15.49 seconds.

4 Answers
4

Leave a Comment