will timers be reset if PC Hibernates and then resumes

mpooley

Active member
Joined
Jan 4, 2009
Messages
32
Programming Experience
Beginner
I have an App that needs to log Data exactly on the quarter hour.(amongst other things)
We have had some power outages lately and the code as is, does not always restart gracefully depending on the outage(very quick off and then back on seems to be the culprit)

So I have installed a UPS and have set the PC to hibernate when the UPS has been on for 5 minutes.
I have re-written the way the code handles the timing by checking real time and resetting the timers .

This is fine and works perfectly when I restart the App but when tested by forcing PC into Hibernate and power back on the Timers seem to know how long they were off and set themselves !

so am I going bonkers ? can it be that the timers keep to their original schedule even though power was off for 5 minutes or more? and if so how does that work? I didn't know windows 7 was that clever lol

Mike
 
On the PC motherboard, is what is called a RTC (real time clock). It's a small chip that keeps time, tied to a 32KHz fundamental mode crystal and to the CMOS battery. Even if you unplug your PC for a week it will still have the right time when you plug it back in.
 
Thanks
I know the time will be correct but I am using a set of timers that do the various jobs needed. I would have thought a timer doesn't know or need to know the correct time and that when resumed it would carry on from where it was?
That is what I assumed but It seems this is wrong.

Maybe the timers adjust themselves by adding the time offline to the Tick count when they closed down?
That is what my code was going to do but It does it all on it's own! I just want to know how?

thanks again
 
Yes that's what I thought!
without the extra code that I wrote to work around the non-existent problem with the timers the Load form code just makes sure the timers are set up to start exactly on the quarter hour then leaves them alone.
So in the case of a restart they would be set up again and this has run continuously for 24/7 for over 3 years with only the odd hitch on a power failure.

as I said I thought I'd have to write extra code for resuming from Hibernation as the load form event does not run. But the new code never runs as it tests to see if the timers Tick events are on the quarter hour and they magically are!

I know I should be happy that its worked out so easy but I do like to know how things work.:eagerness:
Thank for your input

Mike
 
Back
Top