Zitat von
Delphi Help:
Synchronize causes the call specified by Method
to be executed using the main VCL thread, thereby avoiding multi-thread conflicts. If you are unsure whether a method call is thread-safe, call it from within the Synchronize method to ensure that it executes in the main
VCL thread.
Execution of the thread current is suspended while Method executes in the main
VCL thread.
Ich gebe zu, daß die Hilfe da nicht sehr übersichtlich ist. Und das hier
Zitat von
Delphi Help:
Delphi-Quellcode:
procedure TMyThread.PushTheButton;
begin
Button1.Click;
end;
procedure TMyThread.Execute;
begin
...
Synchronize(PushTheButton);
...
end;
halte ich für falsch, denn es würde einen TButton im Thread-Objekt voraussetzen. Eher so:
Delphi-Quellcode:
procedure TForm1.PushTheButton;
begin
Button1.Click;
end;
procedure TMyThread.Execute;
begin
...
Synchronize(Form1.PushTheButton);
...
end;
Grüße, Messie