procedure Queue(AMethod: TThreadMethod); overload;
procedure Queue(AThreadProc: TThreadProcedure); overload;
class procedure Queue(AThread: TThread; AMethod: TThreadMethod); overload;
class procedure Queue(AThread: TThread; AThreadProc: TThreadProcedure); overload;
Queue
causes the call specified by the aMethod
parameter to be executed using the main thread ( main thread ), thus avoiding conflicts between multiple threads . The current thread is passed by the AThread
parameter.
TThread.Queue
is recommended use in situations where you have no assertion if the method to be used is thread-safe .
The image below illustrates how this is done.
Imagecredit: < in> aviyehuda.com
TThread.Queue
is comparable to the method Synchronize
however, with a single exception , relative to the current thread , using the current Synchronize
to thread method is suspended until the method runs on the main thread, in contrast, when using TThread.Queue
the execution of the thread is allowed to continue.