[Lazarus] Thread finalization
Leonardo M. Ramé
l.rame at griensu.com
Wed Sep 21 16:41:56 CEST 2011
On 2011-09-21 16:28:45 +0200, Mattias Gaertner wrote:
> On Wed, 21 Sep 2011 11:12:12 -0300
> Leonardo M. Ramé <l.rame at griensu.com> wrote:
>
> > On 2011-09-21 15:38:08 +0200, cobines wrote:
> >[...]
> > Well, the "best" way I found is to create a Timer that checks if the
> > thread is terminated, then destroy it.
> >
> > I don't like this. It would be better if the thread can communicate the
> > main form that it has finished, then the main form can destroy it,
> > without using a Timer.
>
> Why must the main thread destroy it? The thread can destroy itself.
> Just add a Synchronize call in the destructor or at the end of Execute to let the main thread clear the references.
>
> Mattias
>
So, you say that I should use FreeOnTerminate := true, and set MyThread
:= nil on the main thread?.
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the Lazarus
mailing list