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().
// // 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;
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.