[Lazarus] TThread.Synchronize from anywhere

Luca Olivetti luca at wetron.es
Sat May 10 15:06:51 CEST 2008


En/na Damien Gerard ha escrit:
> Hi !
> 
> I have to use threads in a GUI app.
> I have a class which is descendant of TThread and Synchronize is used  
> to update all Visual controls.
> However most of the functions are not within this class and it is  
> difficult to broadcast the current TThread var.

???
You are either calling these functions from a thread (so the thread is 
finally responsible for calling synchronize), or you're calling them 
from the main thread, so there's no need to call synchronize.
OTOH if these functions are the one uptading the visual control, they 
should be called by the synchronized method, not by a normal function 
method. In any case there's no need for the function to know anything 
about the thread.
If the functions really need to know the thread, maybe they should be 
defined as methods of the thread or one of their parameters should be a 
TThread.

Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007



More information about the Lazarus mailing list