[Lazarus] How to PostMessage to object?

Henry Vermaak henry.vermaak at gmail.com
Thu Jun 9 12:10:46 CEST 2011

On 08/06/11 16:39, Henry Vermaak wrote:
> On 08/06/11 16:28, Krzysztof wrote:
>> Hm, I forgot about Application.QueueAsyncCall. And this can be safely
>> call from thread without TThread.Synchronize() ? Because I don't want
>> use Synchronize() in any part of thread code. So this is correct code? :
>> procedure TMyThread.Execute;
>> begin
>> // <some code here>
>> Application.QueueAsyncCall(@SomeObj.TestMethod, PtrInt(NewStr('Some
>> value')));
>> // <some code here>
>> end;
>> There is no chance for deadlock with main thread calling this from
>> inside another thread?
> You have to protect it with a critical section (if you have more than
> one thread calling QueueAsyncCall).

This will not even solve the problem, since the ProcessAsyncCallQueue 
and RemoveAsyncCalls also need to be protected.  Just use PostMessage 
for thread communication.

More information about the Lazarus mailing list