Solved

Delays

Posted on 1997-03-26
4
474 Views
Last Modified: 2010-04-06
How can I program delay-Routines, like the delay shipped with Borland pascal? I need delays down to microseconds.

Thanks
0
Comment
Question by:hoffi
4 Comments
 
LVL 3

Expert Comment

by:mheacock
ID: 1334967
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.
0
 
LVL 3

Expert Comment

by:sperling
ID: 1334968
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.
0
 

Accepted Solution

by:
slash earned 100 total points
ID: 1334969
OK !!!
Here goes some code, like :

procedure delay(msec:integer);
var first_t:integer;
begin
 first_t:=GetTickCount;
 while ...
  Application.ProcessMesage()
end.

// something like this ... stand by for more
0
 

Expert Comment

by:pam032697
ID: 1334970
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).
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now