Home All Groups Group Topic Archive Search About

System clock events

Author
15 May 2006 2:46 PM
Andreas Håkansson
Hi,

Is there anyway to be notified with the system clock changes? I don't mean
when the user changes the settings, but each time (in my case) it swicthes
minute? I have some code I would like to run each time the minute changes of
the system clock. I could use a Timer object and set it's intervall to a
minute, but then it would only execute within a given minute of the system
clock, I want a trigger when it changes.

I dont mind using interop if thats what is required

Author
15 May 2006 2:58 PM
Barry Kelly
"Andreas Håkansson" <andreas.hakans***@sembo.se> wrote:

> Is there anyway to be notified with the system clock changes?

The system clock changes continuously many times per second. There
aren't separate events for per-minute changes.

> I don't mean
> when the user changes the settings, but each time (in my case) it swicthes
> minute? I have some code I would like to run each time the minute changes of
> the system clock. I could use a Timer object and set it's intervall to a
> minute, but then it would only execute within a given minute of the system
> clock, I want a trigger when it changes.

Your best bet is to look at the current time, and set the interval to
last you until just after the minute has changed. Every subsequent time
the event is triggered, repeat: recalibrate the interval based on the
current time so that the next event is due to happen just after the
minute has changed.

-- Barry
Author
15 May 2006 3:04 PM
r norman
On Mon, 15 May 2006 16:46:21 +0200, "Andreas Håkansson"
<andreas.hakans***@sembo.se> wrote:

>Hi,
>
>Is there anyway to be notified with the system clock changes? I don't mean
>when the user changes the settings, but each time (in my case) it swicthes
>minute? I have some code I would like to run each time the minute changes of
>the system clock. I could use a Timer object and set it's intervall to a
>minute, but then it would only execute within a given minute of the system
>clock, I want a trigger when it changes.
>
>I dont mind using interop if thats what is required
>
Set a Timer object to once/second, then test the second value to see
if it is zero, or else test the minute value to see if it has changed.
Running the timer event processor 59 times when it is not needed seems
like a waste but is a completely negligible use of system time.  It
works well and is simple.  Of course if you need to know the even to
better than one second accuracy, you will have to check more
frequently.

AddThis Social Bookmark Button