![]() |
![]() ![]() ![]() |
acThread component.
|
procedure Synchronize(Method: TThreadMethod);
|
The Synchronize method executes a method call within the main VCL thread. 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 main VCL thread by passing it to the Synchronize or SynchronizeEx methods.
|
|
![]() |
procedure TForm1.SynchronizedOutput;
|
begin
|
OutputBox1.Items.Add(Variable1);
|
Label1.Caption := Variable2;
|
end;
|
|
procedure TForm1.acThread1Execute(Sender: TObject);
|
begin
|
// don't try to make the asynchronous output to the main form's thread.
|
// Do only long-time calculations, then ñall Synchronize method
|
//...
|
StrVariable := StrData1;
|
IntVariable := IntData2;
|
Synchronize(SynchronizedOutput);
|
//...
|
end;
|
SynchronizeEx, Execute, Suspend, Resume and Terminate methods;
|
OnSynchronization event.
|