I have a timer running that sets an event to fire at certain intervals. Apparently, when the computer os goes to sleep it kills the timer. I need it to start up when the computer wakes up again, or better yet, keep firing while the computer is asleep. I found one solution at stackoverflow.com, but the solution doesn't make sense to me.
The answer was to set a timer with a shorter cycle, then have that timer check against a "time to fire" in the future. If the timer in Flex gets shut down on "sleep" then setting a shorter timer cycle doesn't seem like it would solve anything, because the timer gets killed no matter what. What good does setting a timer to check against a system clock time do if the timer gets killed when the system goes to sleep?
The only other answer I've found is forcing the system to stay "awake" while my app is running, but this seems a bit invasive.
So, my question is, how do I set an event listener to detect when the system (os) wakes up?
Setup a timer that fires every x seconds. When the timer event fires grab the current system time and compare it against the system time from when the timer last fired. If the difference between those two system times is much larger than roughly x seconds then you might be able to assume that means the system has just woken up from sleeping.