Re:Help: Thread question.
Hi !
I think you've been mixing "terminate" with "destroy". "Terminate" method of TThread isn't a
destructor. If you set FreeOnTerminate to true, the destructor is invoked on termination of the
thread. Otherwise you'll have to make an explicit call to TMyThread.free;.The natural place to put
the Status.free is in the destructor. The thread needs to be freed somehow, and then is your
TStringList freed, as well.
--
Bjoerge
<<Dodgy skrev i meldingen <378f26db.5335...@news.clara.net>...
I have been playing about with threads, and think I have got the hang
of them (fun aren't they!)
Anyway, I now have to create some workspace in the thread for a
Tstring...
I have already got a custom contructor which reads.....
constructor tmythread.create(somedata:string);
begin
localdata:=somedata;
status:=tstringlist.create;
inherited create(true); //thread does not start until resumed.
end;
Which creates a stringlist.... I have this nagging feeling I need to
do a free on this when I finish the thread, so I guess that's a custom
destructor... Trouble is I can't find any example of one of these
beasts... could someone tell me how I would do it with this example?
I tried
destructor tmythread.terminate;
begin
status.free;
inherited terminate;
end;
But it sort of went POP!
Many Thanks
Dodgy.