We need to insert a bit of a reality check here. Windows provides NO interfaces to a hardware real-time clock. ALL of Windows timing is based off of the periodic firing of the on-board countdown timer -- the tick counter. This timer is notoriously inaccurate, and on many perfectly normal systems is off by as much as 5 seconds per day. For you to expect sub-second accuracy over the period of a day, much less over several months, is simply unrealistic.
If you need a counter to fire roughly every 10 seconds, then the solutions presented are more than adequate. If you have a life-or-death situation that requires exactly 10 seconds, day and night, week after week, then you MUST use an external time base hardware, or an interface to an NTP server. Such things are available, but they will use a custom interface.
I'm curious to know exactly what your application is. I can't imagine a use case requiring multiple months of continuous uptime in which these accumulated errors would be important.
···
On Wed, 10 Nov 2004 12:54:33 +0800, Qiangning Hong <hongqn@gmail.com> wrote:
2. There is still some extra time for calculating (t - time()), although it is very short, but if the timer runs for months, it could become unacceptable.
A good timer, I think, just as wx.Timer, should only calculate the clock ticks of system and independ on the actual system time. And it should hook itself with the hardware clock interface which OS provide. I am just curious about why all this kind of timer are bind to a GUI framework like Windows, GTK, wx, etc.?
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.