Alarm Program - Best way to trigger an alarm on specific time?

Looking for 'best' method to trigger an alarm by date/time.

Page 1 of 1

1 Replies - 4227 Views - Last Post: 17 December 2009 - 09:28 PM Rate Topic: -----

#1 Ewinz87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 25-May 09

Alarm Program - Best way to trigger an alarm on specific time?

Posted 17 December 2009 - 09:01 PM

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!

Is This A Good Question/Topic? 0
  • +

Replies To: Alarm Program - Best way to trigger an alarm on specific time?

#2 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1