[Lazarus] Thread safe

SteveG steveg at nevets.com.au
Sat May 30 17:50:19 CEST 2009

On Saturday 30 May 2009 17:09:41 Mattias Gaertner wrote:
> On Sat, 30 May 2009 12:55:14 +1000
> SteveG <steveg at nevets.com.au> wrote:
> > Would appreciate anybody clearing this up for me -
> >
> > If I use a TTimer on a GUI form to call a function, is the function
> > within the Main thread at all times (therefore gui threadsafe) ?
> yes
> > If the above function then calls a function within a library, is the
> > call still within the main thread (still safe) ?
> Yes.
> Unless the library starts another thread.

One further assumption (to save a little time) - 
If a TTimer is created within the 'Initialization' section of the Laz app, and 
the timer event calls a function within a library, all calls within that 
function, and any functions it calls should be thread/gui safe ?

Assuming the above to be true, can you tell me why the following 'sometimes' 
fails (works about 3 of 5 calls)  when used from within the library function?

I pass the address of a WinCtrl (eg Label) to the function, then use the 
  TLabel( CompAddress^ ).Caption := 'test';

also a problem is 'Application.ProcessMessages' within the library

These (and variations of) seem to fail regularly, but work fine from the Laz 
app itself


More information about the Lazarus mailing list