Thanks Mike but I already wrote the watcher. The OS can't pull data from an
MS SQL database, analyze the data and then post the good rows out to a
remote MySql system. That's what my app does every 10 minutes. I thought
about using the OS scheduler to handle the timing but I'm not really sure
how that could work. I'm guessing the watcher would be initially off, not
loaded at all, and then the OS would call it up and run it at the
appropriate time. The problem is that I'd need to be sure that if the batch
took longer than 15 minutes and the OS is scheduled to run it every 15
minutes then there would be no conflicts. The other thing about having the
watcher running all the time is that it displays status of the posted rows.
If it's being turned on and off all the time the onsite staff person that
monitors it occasionally would have to pull up logs to see what's going on.
It wouldn't be very convenient for them. I really need to be able to just
add some code to my existing watcher that monitors the OS clock and then
runs at specified times that would be stored in my watchers XML config file
(that gets read to set certain params like sql login info when the watcher
starts).
Maybe I'm missing something here that the OS can do that I'm not aware of.
Keith
The windows scheduler would do a "fresh" launch of your app every 15
minutes. One approach for you in the case where a given launch has
taken more than the expected 15 minutes would be to check at app startup
whether there is another instance running. If so, just quit the second
launch.
Based on your information that this posts progress messages for
operators, sticking with your own pseudo scheduler is probably the way
to go. So now it seems as though your question is how to know if "now"
is the right time to do an update. An approach that I would use is to
set a timer where the event handler for the Elapsed event checks two
things: 1. When was the last job done, and B. Is the current time after
some time when the clock is 0, 15, 30 or 45 minutes past the hour. For
part 1, just keep track of the last job completion time. For part B,
you could just look at the Minute property of a DateTime.Now() call.