[Lazarus] Lazarus and Application.ProcessMessages

Lukasz Sokol el.es.cr at gmail.com
Thu Dec 4 16:24:18 CET 2014


Hi,

(for md as well as Michael)

On 04/12/14 08:35, Michael Schnell wrote:
> On 12/03/2014 11:37 PM, Terry A. Haimann wrote:
>> I have a program that starts some background processes and then
>> needs to go to sleep for 15 seconds or so and then come back and
>> check on their statuses.
> 
> A "more decent" way is to leave the current event and use a TTimer
> (e.g. with en event counting down seconds) and do the necessary stuff
> in the timer event.
> 

But sometimes it's totally not practical and worse than that, unmaintainable
to split the set order of execution of the startup procedure like that...

Executing a thread, which would TOO contain Sleep()  in its Execute, and then
calling into next part of the startup procedure ?

(OnTimer execution has the same problem : inevitably splits the procedure into 
more procedures, that can no longer use same local variables and stuff)

(say I need to load some library in OnCreate (or even in initialization), 
 [or be it that I want to load a library on demand, when user wants to use a feature]
that in turn takes some time to initialize itself and does not work properly if
called before some time passes; or if it's clever(er) gives us a status call;
but no other calls may be used in further of my program until the init is complete;
but I don't want the form to freeze while init is going on, but rather have e.g. a progress bar,
and maybe an error message on timeout;)

Or e.g. I run FindFirst/FindNext loop over a large number of files, 
or even if I delegate reading of a file to another procedure, still takes time
while nothing else can happen... (although /that/ actually I can imagine doing in a thread).

Then such Application.ProcessMessages is about the only option ?

> -Michael
> 
Lukasz





More information about the Lazarus mailing list