C
Carl Daniel [VC++ MVP]
Michael said:Anyone,
I'm looking for a way to setup a callback function in our VC++ .net
2003 7.1 console application using a higher resolution timer. The
multimedia timer is too low resolution at 1 millisecond. We need
microsecond resolution to guarantee an exact update rate (60 or 70 Hz
for example.)
We use the Performance Counter to get microsecond resolution when
measuring elapsed time, but there doesn't appear to be any tools for
generating callbacks or interrupts, etc. at that higher resolution.
Any ideas would be greatly appreciated. Thanks,
You need to use an operating system other than Windows if you need
microsecond precision in timing - Windows was simply not designed to do
that.
Your only recourses under Windows are probably:
1. Use a multimedia timer to get close, and then poll at high frequency
until the desired event time.
2. Build (or find) a custom hardware device that generates interrupts at the
desired rate, then write a kernel device driver to service that interrupt.
The video display (if that's what you're updating) could be the source of
that interrupt stream.
If it is a display device that you need to interact with at precise times
(e.g. once per vertical blank), then Direct Draw provides frame
synchronization (which it implements using technique #1 above).
Even with the above techniques you have absolutely no guarantee that your
event will occur with any predictable latency/jitter.
-cd