[Lazarus] Application.QueueAsyncCall and checking if object still exists

Krzysztof dibo20 at wp.pl
Thu Sep 22 12:19:22 CEST 2011


Hi,

I have some object which create and execute thread. This thread do some http
requests (synapse) and send progress to the object by
Application.QueueAsyncCall(MyObject.MyHandleProc, AProgress), it is designed
for multithread - have critical section, so I can call it from thread to
main thread. But I have problem which occurs some times. In object
destructor I clear async queue by calling Application.RemoveAsyncCalls
(which is thread safe too). But if thread waiting in critical section
(because main thread block it with RemoveAsyncCalls) then after main thread
leave critical section, thread post progress but should not because object
is going to destroy. This occurs Access violation in ProcessAsyncCallQueue
because method MyObject.MyHandleProc doesn't exists any more, this is only
pointer to that method. Can ProcessAsyncCallQueue some how check if target
still exists?

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110922/ad5103a7/attachment-0002.html>


More information about the Lazarus mailing list