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.
I would like to call TThread.Synchronize from anywhere but it requires a value for AThread :
class procedure Synchronize(AThread: TThread; AMethod: TThreadMethod);
May be `threadvar` could help me but I don't know if it is a good idea and if it is valid :
type
TMyThread = class(TThread)
protected
procedure Execute;override;
[...]
end;
threadvar
CurrentThread: TMyThread;
implementation
procedure TMyThread.Execute;
begin
CurrentThread := Self;
while not Terminated do
begin
// Loop
end;
end;Any advice ?
