[Lazarus] How to PostMessage to object?

Henry Vermaak henry.vermaak at gmail.com
Wed Jun 8 17:39:33 CEST 2011


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).

Henry




More information about the Lazarus mailing list