Link to home
Start Free TrialLog in
Avatar of hoffi
hoffi

asked on

Delays

How can I program delay-Routines, like the delay shipped with Borland pascal? I need delays down to microseconds.

Thanks
Avatar of mheacock
mheacock

The MMSYSTEM dll comes with very fine timer utilities, but will only get down to a single millisecond.  I don't know of anything that will get you down to microseconds.

I'll watch the answer tho...I'll be curious if this is possible at that fine a resolution.
As mheacock's already really answered the question, I'll submit this as a comment...

You can get an approx. maximum timing resolution of 10ms using timers, or repeated calls to GetTickCount.

You can get an maximum resolution of 1ms using multimedia timers...

Finer resolution is possible, though, using drivers to reprogram the hardware timer, and so on... That's a heck of a lot of work, and it'll slow down the system *a lot*. It might be possible to do it in user-mode, I do believe I once read an article about how to get 100-200 ns resolution without drivers... Not sure though.

You might wan't to ask your question in the MS-Windows Programming topic area, as this ain't something you'll be able to do in Delphi anyway.

Regards,

Erik.
ASKER CERTIFIED SOLUTION
Avatar of slash
slash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i prefer not to use Application.ProcessMessage.

under NT 4.0 the Task Manager reports a 100% userProcessor used when you have Application.ProcessMessage. I will use the win32 function sleep() instead with a small number.

just use the windows unit, and use sleep(MilliSecond).