I try to call a function every 1 ms. The problem is that I like to do this with windows. So I tried the multimedia API.
Multimedia API
Source
idTimer = timeSetEvent( 1, 0, TimerProc, 0, TIME_PERIODIC|TIME_CALLBACK_FUNCTION );
My result was that most of the time was 1 ms, but sometimes I get a double period. Look at a little punch for about 1.95 ms multimediatimerHistogram http://www.freeimagehosting.net/uploads/8b78f2fa6d.png
My first thought was that maybe my method worked for too long. But I already measured it, and it was not.
Queue Timer API
My next attempt was to use the queud timers APIs with
hTimerQueue = CreateTimerQueue(); if(hTimerQueue == NULL) { printf("Error creating queue: 0x%x\n", GetLastError()); } BOOL res = CreateTimerQueueTimer( &hTimer, hTimerQueue, TimerProc, NULL, 0, 1,
But the result was not as expected. Now I get most of the time a 2 ms loop. queuedTimer http://www.freeimagehosting.net/uploads/2a46259a15.png
Measurement
To measure time, I used the QueryPerformanceCounter and QueryPerformanceFrequency methods.
Question
So, now my question is, did someone encounter similar problems under windows and maybe even find a solution?
Thank.
c ++ windows winapi timer real-time
schoetbi Jul 29 '10 at 9:32 2010-07-29 09:32
source share