RAD Studio VCL Reference
TThread.StaticSynchronize Method

Executes a method call within the main thread.

class procedure StaticSynchronize(AThread: TThread; AMethod: TThreadMethod);
__fastcall StaticSynchronize(TThread AThread, TThreadMethod AMethod);

StaticSynchronize causes the call specified by AMethod to be executed using the main thread, thereby avoiding multi-thread conflicts. The current thread is passed in the AThread parameter.  

If you are unsure whether a method call is thread-safe, call it from within the StaticSynchronize method to ensure that it executes in the main thread.  

Execution of the current thread is suspended while Method executes in the main thread.

Warning: Do not call StaticSynchronize from within the main thread. This can cause an infinite loop.
Note: StaticSynchronize simply invokes Synchronize with the same parameters.
Note: You can also protect unsafe methods using critical sections or the multi-read exclusive-write synchronizer.


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!