Hello there, I just decided to recode my personal alarm program from scratch, new functions, ui etc and optimize it but I'm stuck on a part.
I have the option to start an alarm and set it to expire at a specific time, say in 2 days 5 hours 18 mins 10 secs. I was wondering what would be the best way (performance wise) to achieve this..
On my old version I'm using a timer with an interval of 1 millisecond which on tick, checks if the specific time is equal to the system one but I don't really like that option although it gets the job done, I don't think it's a great way to do it.
So I was thinking and came up with another idea. Basically I'd do math, taking the specified time/date and subtract it with the current system time and convert it to milliseconds to I can use this final number as interval but I'm still not set on this option.
Looking for insight on which path to take, should I go with my old method, take the new second method or go with a completely other method?
Happy holidays and best wish to all of you!
Alarm Program - Best way to trigger an alarm on specific time?
Page 1 of 1
Looking for 'best' method to trigger an alarm by date/time.
1 Replies - 4310 Views - Last Post: 17 December 2009 - 09:28 PM
Replies To: Alarm Program - Best way to trigger an alarm on specific time?
Re: Alarm Program - Best way to trigger an alarm on specific time?
Posted 17 December 2009 - 09:28 PM
Note that windows real time clocks do suffer from some time shift, so depending on the accuracy you desire, your second idea is a good one - do the math and set a timer - if you really care about 1 second over several days, then just take out a few seconds and recheck every half-second when you get near. What I suspect things like PDAs do is check every minute if something is due - takes a few milliseconds (noise). They could check for the next event and wait, but that can lead to very complex code and likely result in more bugs.
Page 1 of 1