At 06:27 AM 27/02/2006, Arno Garrels wrote: >Hello, > >When I run the code below in D7 as well as BDS2006 I get an EThread >exception with message "Invalid handle(6)". In D5 there was no problem >with the same code. Has anybody any idea why that happens? > >Thanks, > >Arno Garrels > >var >AThread : TThread; > >procedure TForm1.FormCreate(Sender: TObject); >begin > AThread := TThread.Create(True); > AThread.FreeOnTerminate := True;
Hi Arno, I did a lot of thread work in D3 in my last job, and came to the conclusion never to set FreeOnTerminate to true. There were many, many issues with the thread finishing before I expected only to have AV's etc, that I felt it was safer to free it myself - at least I knew I could access data and when it was and wasn't available. If you want to force destroy the thread, then you can suspend it and kill it just as easily if FoT is false. Cheers, Chris. _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

