Arno Garrels wrote:
> 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?

There were huge changes to TThread sometime after Delphi 5. They were 
for the better, but the class works differently now, so your old code 
won't necessarily work as-is.

> var
> AThread : TThread;
> 
> procedure TForm1.FormCreate(Sender: TObject);
> begin
>     AThread := TThread.Create(True);
>     AThread.FreeOnTerminate := True;
> end;
> 
> procedure TForm1.FormDestroy(Sender: TObject);
> begin
>     AThread.Destroy;
> end;

That code doesn't do anything useful at all. It creates a paused thread, 
sets a property, and destroys the thread. Destroying the thread forces 
the thread to resume, at which point the thread will call the abstract 
Execute method and crash. I don't care to investigate what happens after 
that; cross-thread exceptions are something I try to avoid.

-- 
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to