Is their a way to execute a delegate or event in C# when for instance the seconds, minutes, hours,... change in the system-clock, without using a timer that checks every millisecond if the property has changed and executes the event with a delay of maximum a millisecond.
+4
A:
You can subscribe to SystemEvents.TimeChanged. This fires when the system clock is altered.
Reed Copsey
2009-09-16 16:24:32
According to the docs, this fires only when the user changes the system time. This is probably not what CommuSoft wants. Well, or it is, if he wants to find out when the user tampers with the time, as a software protection feature...
OregonGhost
2009-09-16 16:39:07
+3
A:
If your question is: "How do I execute a delegate every full second/minute/hour?"
For minute and hour intervals, you could do something like shown in my answer in this SO question:
This should be fairly accurate, but won't be exact to the millisecond.
For second intervals, I'd go with a Timer with a simple 1-second-interval. From a user's perspective I think there's not a lot of difference if the action executes at xx:xx:xx.000 or at xx:xx:xx.350.
dtb
2009-09-16 16:25:09