Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting an event to run every hour

Hey there!

 

So I'm developing a clock face and am currently looking for a way to ensure an event is ran every hour, preferably on the hour (:00). 

 

The ontick event does not run while the display is asleep, so this isn't ideal... 

 

I was considering setting an setTimeout event when the display gets turned off, with the duration being set to how long is remaining until the new hour. Would this work?  If not, is there any way to achieve what I'm looking for?

Best Answer
0 Votes
1 REPLY 1

That's the best you can do. Just be aware that if the user isn't running your app at the top of the hour, the timeout won't occur. You might want to keep track of when the previous timeout occurred so that, when your app starts, you can detect whether it's been over an hour and take appropriate measures.

Peter McLennan
Gondwana Software
Best Answer
0 Votes