在 Flex 中,检测操作系统是否从待机/休眠/睡眠状态恢复的最佳方法是什么?
我需要能够知道操作系统何时从睡眠/休眠/待机状态恢复。
我遇到的问题是我有一个计时器需要在特定时间触发。延迟是经过计算的,以便它会在特定的小时:分钟:秒触发。问题是当操作系统进入睡眠状态时,计时器会“暂停”,这会导致计时器在错误的时间触发。我希望能够在操作系统从睡眠状态恢复时更新计时器延迟,但似乎没有办法做到这一点......
I need to be able to tell when the os has came back from sleep/hibernate/standby.
Problem I'm having is that I have a timer that needs to fire at certain time. The delay is calculated so that it will fire on certain hour:min:sec. Problem is when the os goes to sleep, the timer is "paused," which caused the timer to fire on wrong time. I would like to be able to update the timer delay when the os comes back from sleep but there doesn't seem to be a way to do this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Flex 中您能做的最好的事情就是使用更快的计时器并跟踪计时器上次触发的时间。因此,不要将计时器设置为从现在起几小时后触发,而是将其设置为从现在起一分钟后触发,并继续触发并检查当前时间与到期时间,直到触发真实事件的时间。
如果计时器在这些过渡时间内所做的所有事情都是根据到期时间检查当前时间,则不会对性能产生可测量的影响。
The best you can do in Flex is use a faster timer and keep track of the last time the timer fired. so instead of setting a timer to fire a few hours from now, set it to fire a minute from now and keep firing and checking current time vs due time until it's time to trigger the real event.
If all the timer is doing during these interim times is checking current time against due time, it won't have a measurable effect on performance.