[Lazarus] TThread.Synchronize

LacaK lacak at zoznam.sk
Wed Oct 26 09:49:44 CEST 2016

>>> ShowModal() for a modal form will call it.
>> Ah really?
>> It happens in my application!
> Then that is  your problem.

>> But is it correct behavior ? IMO it is against thread safety, which 
>> should Synchronize guarantee!
> The two issues are completely unrelated. The current behaviour is 
> correct.
I did test in Delphi and Delphi seems also perform synchronize upon 

> Nowhere is it stated or guaranteed that synchronisation cannot happen 
> in a GUI event
> handler. 

But cann't happen if nobody calls ProcessMessages or CheckSynchronize 
So if user code is executed in event handler then this execution cann't 
be interrupted by thread waiting for "synchronization"

> Any code at any time can call the GUI message loop. A modal form is
> just one instance.

ModalForm is IMO one example but may be alone in LCL ... as there are no 
more controls which do same, does not ?
So in my mind it is very specific case, which should be documented.
Of course there can be any user defined control which will do same ...

> Your code must be able to deal with this.
Yes, thanks


More information about the Lazarus mailing list