Solved

Delays

Posted on 1997-03-26
4
484 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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