Hi all i want to execute code similar to a Interrupt service routine after a timer expires(say print hello after every 10ms) and this is a supplementary activity so it has to be using a timer .So how do i implement timers in vc++
views:
367answers:
2
+1
A:
You want to use the CreateTimerQueueTimer() function. Here is the MSDN sample code.
If you need something that runs on older platforms you're stuck with SetTimer(), which delivers a WM_TIMER message to your WNDPROC. It's a pretty terrible API, so I'd really recommend using the Timer Queue function.
CreateTimerQueueTimer() will spawn a worker thread which does the work of figuring out how much time has elapsed and then call you back when it pops. There are threading implications, but it is much nicer overall, especially if you don't want to have a Window.
jeffamaphone
2009-09-01 06:07:24