Hi Chris
Unfortunately Microsoft does not make real-time operating systems. You
cannot guarantee timer accurracy.
For instance, under DOS and Windows 3.1 the hardware timer ticks were at
approximately 18 a second (A day divided by 2^16 if I remember correctly).
It was quite common to get no events for up to a second, then a single timer
event. This was by design - timeouts are generally low priority for business
applications.
You may be able to improve your program by asking for the system time on
each timer event. You will then have some idea of how long it was since the
last time the timer was serviced. If that is no help, then you are into the
murky world of writing a device driver (I've managed to avoid that myself).
Regards
Ron
[quoted text, click to view] "Chris Winstanley" <spam_avoid_cnw@zoom.co.uk> wrote in message
news:3f79d4c2$0$24268$afc38c87@vipnews...
> Hi,
>
> I'm running version 1.0 of the .net framework on windows XP and Windows
> 2000.
>
> I need to run a timer that fires accurately at a 10ms interval. I've
> been having problems trying to get a System.Threading.Timer to run
> accurately at this rate (it seems to wander around 12ms to 20ms). The
> code running on the timer takes only 3ms to execute. All measurements
> have been done using QueryPerformanceTimer.
>
> I've also noted that there doesn't appear to be any way to set the
> thread priority of a timer.
>
> At the moment I'm considering ditching the timer and simply doing a busy
> wait using QueryPerformanceTimer to give me the accuracy I require.
>
> Surely there is a better way to achieve the accuracy I require?
>
> One more question: If the System.Threading.Timer does overrun it appears
> that another instance of the timer is created and run concurrently. This
> is fine until you attempt to dispose of the timer. The timer is disposed
> in one instance, another instance fires and exceptions because the timer
> handle is now null. Is there anyway to ensure all the timer instances
> are disposed of in one go?
>
> Thanks,
> Chris Winstanley
>