The function Delay() allows access to other events during the delay. For instance a certain key could be used to interrupt a lenghty delay. The Win32 API function Sleep() ignores events, maybe it should be called DeepSleep().
An improved Sleep function
//
// delay in milliseconds, uses the system time, also uses
// Application.ProcessMessages, which allows access to other events
// during the delay, the Win32 API function Sleep() does not
//
procedure Delay(msecs: integer);
var
FirstTickCount: longint;
begin
FirstTickCount := GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount-FirstTickCount) >= Longint(msecs));
end;
nnolte 5 Newbie Poster
tucode 0 Newbie Poster
andre.vanzuydam
Duoas 1,025 Postaholic Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.