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

Flávio Etrusco flavio.etrusco at gmail.com
Thu Sep 22 14:41:10 CEST 2011


2011/9/22 Krzysztof <dibo20 at wp.pl>:
> 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
>

Why not destroy it with Queued call too?

-Flávio




More information about the Lazarus mailing list