Solved

Sleeping in Delphi 1.0

Posted on 1998-03-06
1
263 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
[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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

623 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