[fpc-pascal] changes in TThread.OnTerminate in fcp-3.0?
Henry Vermaak
henry.vermaak at gmail.com
Thu Dec 10 11:20:48 CET 2015
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
More information about the fpc-pascal
mailing list