Solved

Sleeping in Delphi 1.0

Posted on 1998-03-06
1
244 Views
Last Modified: 2010-04-06
How do I make my application sleep for a number of seconds in Delphi 1.0?
0
Comment
Question by:nickcadge
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1360205
Hi nickcadge

Delay, pause, wait


How do you get your Delphi app to do nothing for a period of time?
A:
Uses
     ....
     Winprocs
     ....;

Procedure delay(millisecs : longint);   { delay for given milliseconds }
var
     endtime   : longint;
begin
     endtime := gettickcount + millisecs;
     while endtime - gettickcount < 0 do
          Application.ProcessMessages;
     end; { delay }

A:
procedure Wait;
var oldTime: LongInt;
begin
  oldTime := GetCurrentTime;
  repeat
   { whatever}
  until GetCurrentTime - oldTime >= yourDelay;
end;

To which I would add:

As current Windows does not have pre-emptive multi-tasking,
it's normally good event-handling manners to allow Windows
to jump in to the gap, so the { whatever } above should
usually read:

          Application.ProcessMessages;


A:
Procedure Delay(DTime : LongInt);
Var
  L : LongInt;
Begin
  L := GetTickCount;
  While (Abs(L-GetTickCount) < DTime) do;
End;

The usage is "Delay(1000'th of a second)", for example
Delay(5000) will wait 5 seconds.

Regards, Zif.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

23 Experts available now in Live!

Get 1:1 Help Now