[Lazarus] TThread.Synchronize

LacaK lacak at zoznam.sk
Tue Oct 25 14:46:52 CEST 2016

>> Check for Application.ProcessMessages and CheckSynchronize calls. 
>> These process synchronize queue, if I am not mistaken.
> I do not call CheckSynchronize nor ProcessMessages in my application.
> So only any LCL component or widget set can call it in background ?
 From Delphi doc:
"Synchronize causes the call specified by AMethod to be executed using 
the main thread, thereby avoiding multithread 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 thread.
Execution of the current thread is suspended while the method executes 
in the main thread. "

Looking from where is called CheckSynchronize:

- TWin32WidgetSet.AppProcessMessages

- win32callback.inc:
      case Msg of
       if (Window = Win32WidgetSet.AppHandle) then

Cann't something send WM_NULL to application which can as reaction run 
sheduled thread ?
WM_NULL sends HandleWakeMainThread() which is handler stored in variable 

Messages in win32callback are processed by "main thread" only, so 
execution cann't happen while form method is executed ?


> -Laco.

More information about the Lazarus mailing list