thread Synchronize method
Return to Introduction  Previous page  Next page
Applies to
auThread component.  

Declaration
procedure Synchronize(Method: TThreadMethod);  

Description
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.  
 
tip Execution of the thread is suspended while Method is executing in the main VCL thread.  

Example
procedure TForm1.SynchronizedOutput;  
begin  
  OutputBox1.Items.Add(Variable1);  
  Label1.Caption := Variable2;  
end;  
 
procedure TForm1.auThread1Execute(Sender: TObject);  
begin  
  //...  
  StrVariable := StrData1;  
  IntVariable := IntData2;  
  Synchronize(SynchronizedOutput);  
  //...  
end;  

See also
Execute, Suspend, Resume and Terminate methods.  
File not found.