Mega Code Archive

 
Categories / Delphi / Examples
 

Yield the cpu to other tasks

The function you should use is Application.ProcessMessages. There is also an API function called Yield that seems to do the same thing, but it isn't safe to use from most Delphi applications. Steve Teixeira explains: "You should not use Yield() unless your application is *guaranteed* not to receive any messages (ie, your application contains no windows). Instead, the way to do this in Delphi is to call Application.ProcessMessages. ProcessMessage encapsulates a PeekMessage() loop, which is the correct "API-way" to do this."