Long Timer Period

Hello,

Is there any problem with using a long timer period - like 12 hours - 43,200,000 milliseconds?
Must this be broken in to smaller chunks?
Does anyone know, or recommend the max period - or is it limited by the Integer (32) value?

Thank you,
Tim

In principle, the maximum period is limited to the upper bound of the Integer datatype (i.e. 2,147,483,647 milliseconds, roughly 600 hours.) However, for periods longer than an hour or so I usually use the OS’s scheduling capabilities (cron on Linux/Mac, Task Scheduler on WIndows.)

[quote=23507:@Tim Seyfarth]Hello,

Is there any problem with using a long timer period - like 12 hours - 43,200,000 milliseconds?
Must this be broken in to smaller chunks?
Does anyone know, or recommend the max period - or is it limited by the Integer (32) value?

Thank you,
Tim[/quote]

If I remember correctly you cannot rely on a timer to be exact or near exact with it’s functioning as different processes may interfere with it.
If that is true then perhaps the longer your timer period the greater the error.

If you need exact or near exact timed actions you may want to use a timer to poll the system’s time and do your calculations as needed.

If I’m wrong on this then I hope someone will correct me.

You’re not wrong. The interval between each firing of the timer is no less than the period, but often more.

Yes, you are correct Mason. In my case, some degree of randomness in my application is actually helpful.
I normally use timers in periods of less than milliseconds. In those cases, precision is often more important, but again, realizing and taking the limitations of the object into account during design, are important.

Thank you all again for your replies!
Tim

I would make a timer firing every hour and just check if we reached the point in time you want.
Due to several things like time zone changes, the time may switch for and back.

Note that OS X 10.9 uses “TimerCoalescing” and App Nap which can mean that timers don’t fire when you expect them to: http://www.apple.com/osx/preview/advanced-technologies.html

If I’m right the timer thing in Mavericks is optional.

I believe there is a way to have a program opt-out, but we probably shouldn’t discuss that as I think it’s under apple NDA right now. :slight_smile: