Solved

Delays

Posted on 1997-03-26
4
493 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 92
Help on project with Soap 10 63
When i run adoquery my application freezes 26 190
Delphi: barcode reading on android platform 1 73
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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