Click to See Complete Forum and Search --> : Timer-Interrupt on NT


Markus Lemke
February 27th, 2002, 06:55 AM
Hallo,

does someone know how to program a timer interrupt on NT? My goal is to start a short function every millisecond.

If anyone has a hint, i would be grateful.

Markus

NMTop40
February 27th, 2002, 08:48 AM
Yes, use the timer commands.

SetTimer() will give you a timer object and a WM_TIMER will be generated when that timer is set.

And you can use WaitForSingleObject on the timer handle (that is returned by SetTimer)




The best things come to those who rate

Andreas Masur
February 27th, 2002, 09:42 AM
The standard windows timer (like 'SetTimer()') wouldn't help you in this case. They are simply not accurate enough. If you need measure within the millisecond range you need to think about other possibilities. Since the standard posts 'WM_TIMER' messages to a message queue, and you can never be sure when this message will be processed.

In your case I would suggest using waitable timers. The main purpose of these timers is thread synchronization. They are kernel objects which will be signaled in the specified time, or in regular time intervals. They can specify the callback function (actually, an asynchronous procedure call, or APC) which gets called when timer gets signaled...there are unfortunately some downsides of these timers which reduces the usability significantly...

Take a look at http://www.codeproject.com/system/timers_intro.asp for a overview of all available timers in windows operating systems...

Ciao, Andreas

"Software is like sex, it's better when it's free." - Linus Torvalds