[Lazarus] LCL messaging system SendMessage and Multi-Threads
Andrew Brunner
andrew.t.brunner at gmail.com
Fri May 7 16:21:02 CEST 2010
> That is what Synchronize has been invented for: Execute some of the
> thread code in the main thread.
I had given up on that and went with a SendMessage System under windows.
I rarely use it for GUI work but recently the OnSelectItem of the
ListView in Ubuntu
is posting up to 3 OnSelectItem events every time I select an item. So my timer
system is ideal for refreshing the TTL on the item before it executes
the procedure.
> When calling Synchronize the thread stop at this point. the synchronized
> method is scheduled to be executed in the main thread. When (after a
> possibly very long time) the main thread is ready to execute that
> method, it does so and after that wakes up the thread.
> Disadvantage: the worker thread might stop for a very long time.
Yes. I realize that. But it is a necessity for doing GUI work since
Gnome or GTK2
won't accept visibility changes from outside threads...
> To prevent the thread from stopping, PostMessage() can be used and the
> "synchronized" Method now is defined by procedure ... message in of some
> Form.
>
> Disadvantage: you need to take care of protecting commonly used resources.
SendMessage did not work. Visibility as not able to be changed. Only
synchronize worked.
Thanks for your insight - solved the issue in like the first 10 minutes ;-)
Consequently I really am disappointed at the process GDM @ least for
Ubuntu x64. The GDM
keeps crashing on mult-thread debugging and you can't do squat with
GUI components from
threads.
More information about the Lazarus
mailing list