C
Chris Winstanley
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
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