Mega Code Archive

 
Categories / Delphi / Examples
 

Wait for an amount of milliseconds

The Win32 API has the function Sleep(ms : longint); for this purpose. If you are working with D1, use the following function - it waits for a given amount of milliseconds. It allows the current application and other applications to process incoming messages: procedure Delay(ms : longint); var t1 : longint; begin t1 := GetTickCount; while (GetTickCount - t1) < ms do Application.ProcessMessages; end;