On Thu, Dec 10, 2015 at 10:26:29AM +0100, Luca Olivetti wrote: > Hello, > > in a couple of programs I'm using this idiom: > > > FMyThread:=TMyTread.Create; > FMyThread.FreeOnTerminate:=false; > FMyThread.OnTerminate:=@MyThreadTerminate > > procedure TMyForm.MyThreadTerminate(Sender:TObject); > begin > //do something with FMyThread then > FreeAndNil(FMyThread); > end;
This is why FreeOnTerminate exists. Set that to True and set FMyThread to nil here, and the thread will free itself after this function returns. Henry _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal