[Lazarus] Windows.PostMessage vs Application.QueueAsyncCall
Marcos Douglas
md at delfire.net
Mon Mar 17 13:31:50 CET 2014
On Mon, Mar 17, 2014 at 6:56 AM, Michael Schnell <mschnell at lumino.de> wrote:
> On 03/16/2014 02:47 AM, Marcos Douglas wrote:
>>
>> Like all Windows programmer, I use PostMessage/SendMessage a lot.
>> Lazarus team has created Application.QueueAsyncCall method to
>> substitute the (old) "Windowish" method todo async calls aka
>> PostMessage.
>>
>> Ok. But what is the best way to use QueueAsyncCall when the caller to
>> not knows what type is the receiver?
>
> As QueueAsyncCall does not exist in Delphi you might want to avoid it to
> stay Delphi compatible.
I don't care about Delphi compatibility. Today I only use FPC/Lazarus.
> So you can use TThread.Queue that is available both in Delphi (even though
> undocumented in some older versions) and in Lazarus/fpc (even though only in
> the not too old versions).
>
>
>> QueueAsyncCall need to know the instance and the method to call...
>
> QueueAsyncCall is given the procedure to call and a parameter for same, but
> no "instance". TThread.Queue only gets the (parameter-less) procedure to
> call.
Yes, but the QueueAsyncCall needs to know what procedure to call for a
especific object (instance).
Of course you can "simulate" not to know which instance calling this
procedure and the implementation will instanciate the especific
class... adding complexity IMHO.
Using PostMessage you can send a broadcast.
Marcos Douglas
More information about the Lazarus
mailing list