Re: Delay in milliseconds and need info abt Multimedia timers

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Mahesh BS wrote:
Hello,

I am trying to develop application which needs some delay to be
introduced. Here I need to introduce a delay of few micro seconds. Using
Multimedia timers I could get a lowest delay of up to 1 ms.

1) Can anybody help me in knowing how can we achieve a delay of few
millseconds on VC++.

Which is it, microseconds or milliseconds?

2) Does anybody have an idea about the accuracy of the multimedia timers.

If you call timeBeginPeriod(1), you get 1ms roughly (wakeups on the whole will be between 0 and 1ms late), and that's the best blocking wait accuracy available on Win32.

If you need a delay of a few microseconds, a non-blocking busy wait using QueryPerformanceCounter is the way to go, making sure your process priority class is set to REALTIME_PRIORITY_CLASS.

Note that it is hard to guarantee any particular accuracy on Windows since it isn't a realtime system, but you should be able to get good "average" scheduling.

Tom
.



Relevant Pages