Problem with Timer firing reliably



Can anyone suggest a fool-proof way to execute a procedure *reliably*
at a certain time of day?

I have an app that runs 24/7. There are several activities that need
to be done each day at a specified time. To handle this, I have a
timer that runs with its interval set to 1000 ms. Every time it fires,
I display the time on the main screen using this statement:
frmMain.StatusBar1.Panels(3).Text =
Format$(Time$, " H:MM:SS AMPM")

I then capture the displayed value like so:
TimeCaption$ = Trim$(frmMain.StatusBar1.Panels(3).Text)

And compare it to the scheduled times when things need to happen, thus
(for example):

If TimeCaption$ = "7:59:55 AM" Then Call SomeProcedure()


I've been using this approach for several years in a lot of different
installations and it seems to work just fine about 99.999% of the
time.

The problem is, it does not work 100% of the time. Once in a great
while (like once or twice a year), SomeProcedure does not get called.
I am assuming that once in a great while, something will bog down the
computer at just the wrong moment and the timer will fire late and the
time caption will go from "7:59:54 AM" to 7:59:56 AM" and thus I'll
never get the match I'm looking for.

I've considered putting in a "latch" that would be set when the
procedure DOES execute and then check that at "7:59:56 AM" and, if it
was not set, then call the procedure. Is this the "best" way to handle
it?

Any other thoughts as to how to fix this?

Thanks.
.


Loading