Mark Morgan Lloyd wroteThanks for that, useful. That's going to impact anybody trying to convert code that uses custom Windows messages to pass events around.
For Delphi users, it is a common (bad) habit to use PostMessage() for Thread to MainThread signaling. It was necessary pre D7. But as of D7, for this purpose there is TThread.Queue() (which only was documented only as of a later version of Delphi).
Unfortunately only the SVN version of the FPC RTL provides TThread.Queue() (implemented some time ago on my request THANKS !!! ), But no officially released version has it yet.
A long time ago, I did a testing program that with an arbitrary Widget Type checks the "compileability" and the workability of
- TThread.Synchronize
- TThread.Queue
- PostMessage
- PostThreadMessage (AFAIK not implemented in Lazarus Linux)
- SendMessage ()Forbidden to be called in a Thread)
- Application.QueuAsycCall
- Application.QueuAsycCall with additional parameter
I separated the business Logic and GUI to prepare it to test the "ActiveNoGui" (to be renamed to "GeneralServiceApplication") Widget Type, I intend to do and provide to be include into Lazarus. (In fact the draft of same does have most of this but still is lacking "PostMessage".
Show quoted text 6 lines
Yep. As the "Main Loop" of the "GeneralServiceApplication" Widget Type uses the timeout of CheckSynchronize to implement TTimer, it can't call RemoveAsyncCalls(). So I implemented TApplication.QueuAsyncCall() by means of TThread.Queue (using a transfer class with a a would-be "Finalizer" procedure).
-Michael
