2 Nov
2009
2 Nov
'09
2:22 p.m.
Sturla Molden skrev:
I would turn on multimedia timer (it is not on by default), and replace this call with a loop, approximately like this:
for (;;) { r = WaitForMultipleObjects(2, objects, TRUE, 0); /* blah blah blah */ QueryPerformanceCounter(&cnt); if (cnt > timeout) break; Sleep(0); }
And just so you don't ask: There should not just be a Sleep(0) in the loop, but a sleep that gets shorter and shorter until a lower threshold is reached, where it skips to Sleep(0). That way we avoid hammering om WaitForMultipleObjects and QueryPerformanceCounter more than we need. And for all that to work better than just giving a timeout to WaitForMultipleObjects, we need the multimedia timer turned on. Sturla