[Lazarus] Application.QueueAsyncCall and checking if object still exists
Michael Schnell
mschnell at lumino.de
Fri Sep 23 10:06:31 CEST 2011
On 09/22/2011 05:28 PM, Krzysztof wrote:
>
> Main problem is: I don't know how to tell thread (which is locked in
> QueueAsyncCall critical section), that method pointer which he trying
> to post, doesn't exists anymore.
>
Seemingly you want to create a queue of objects and/or strings that are
sent from the Thread to the Main thread, and want to be sure that the
main thread in fact handles all of them.
If just doing a progress indicator, it would not harm if some events in
the main thread would be dropped, so IMHO it would be a better way to
use a global integer variable that is written by the thread and read by
the main thread. So no object or string creation is necessary.
If you really need to dedicatedly handle all events I;HO a good way is
to use a TThreadList with "add" in the thread.
Another thing to watch is how the reference counting strings are
handled. Are they correctly kept life when the function that moves them
into the object is left ? Are they correctly freed when the object is
freed ?
I usually try to avoid handling strings in such a creative way.
-Michael
More information about the Lazarus
mailing list