Hello experts, I need to call a method in my console app/win service at precise moments of the day. When I say precise I mean +/- a few seconds. The number of events triggered and the time of the day when they should be triggered is variable. If only one method call must be performed, then it should always be approximately at the same time of the day, say midnight. If two events are to be fired, they should be say 12 hours apart, noon and midnight, and so on. The configuration part I can handle. I need some ideas on how to trigger the events. I thought about having a dedicated thread where I would have lots of sleep periods in an infinite loop. After each sleep period, I could compare the current time with the time of the next event that must be fired. The event would have to be fired in X seconds and I would enter in a new sleep period for X/2 seconds. Eventually, the difference between the current time and the time of the next event would become smaller that an acceptable delta, at which moment I would fire the event and would enter in a new sleep period. This way the events would always be fired at approximately the same times of the day, and I wouldn't have to worry about the moment when the application/win service was started. I am not particularly proud of this solution as it seems kind of empiric, but I just couldn't think of anything else. Can you gals and guys come up with a more elegant and reliable approach?
TIA, Eddie =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
