[Lazarus] TThread.Synchronize

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Oct 26 10:13:29 CEST 2016


On Wed, 26 Oct 2016 09:49:44 +0200
LacaK via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

> >>> ShowModal() for a modal form will call it.  
>[...]
> I did test in Delphi and Delphi seems also perform synchronize upon 
> ShowModal

Yes.


> > 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 
> explicitly.
> So if user code is executed in event handler then this execution cann't 
> be interrupted by thread waiting for "synchronization"

Yes. 
Unless you call something that does call HandleMessages/ProcessMessages
or CheckSynchronize.

 
> > 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 ?

The dialogs like TOpenDialog and ShowMessage call it.
Another example is reading the Clipboard on gtk and retrieving files in
TShellTreeView.


Mattias


More information about the Lazarus mailing list