Ok, this can be done with critical section but what with AV scenario? Example:<div>1. Thread add queue calling <meta http-equiv="content-type" content="text/html; charset=utf-8">Application.QueueAsyncCall(MyObj.EventMethod, 0);</div>
<div>2. MyObj is destroyed by main thread</div><div>3. Main thread process messages and try call queue added by thread but reference to MyObj.EventMethod was destroyed by previous message loop. This cause Access Violation.</div>
<div><br></div><div>I could remove this queue in MyObj destructor but TApplication.FAsyncCall is in private section :/</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>
<br><div class="gmail_quote">2011/6/8 Henry Vermaak <span dir="ltr"><<a href="mailto:henry.vermaak@gmail.com">henry.vermaak@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 08/06/11 16:28, Krzysztof wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hm, I forgot about Application.QueueAsyncCall. And this can be safely<br>
call from thread without TThread.Synchronize() ? Because I don't want<br>
use Synchronize() in any part of thread code. So this is correct code? :<br>
<br>
procedure TMyThread.Execute;<br>
begin<br>
   // <some code here><br>
   Application.QueueAsyncCall(@SomeObj.TestMethod, PtrInt(NewStr('Some<br>
value')));<br>
   // <some code here><br>
end;<br>
<br>
There is no chance for deadlock with main thread calling this from<br>
inside another thread?<br>
</blockquote>
<br></div>
You have to protect it with a critical section (if you have more than one thread calling QueueAsyncCall).<br><font color="#888888">
<br>
Henry</font><div><div></div><div class="h5"><br>
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
<br>
</div></div></blockquote></div><br></div>