Use the Terminate Method of the thread (as you do in the sample code for
button2). Then in your thread's execute method you need to regularly
check the thread's Terminated method.
eg:
While not Terminated do
begin
//task
end;
if not Terminated then
begin
end;
etc etc
Phil.
Nick Fauchelle wrote:
Hey guys,
I got a thread here (TFetchData = class(TThread)) which downloads a
bunch of xml and then process's it and sticks it into a database.
All working well, however I want the user to be able to
abort/terminate the process...
So one think I did is setup a global varaible - gbTerm : boolean;
And in my thread.execute I would do this
If gbTerm = true then terminate;
However that didn't quite work as expected (ie, nothing happened,
thread still ran).
So then I tried
var
MyThread : TFetchData;
begin
MyThread := TFetchData.create('myname');
end;
button2
begin
MyThread.Terminate;
end;
same result as above (to be expected ofc).
So im just wondering... how should I terminate this thread?
Thanks
Nick
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
begin:vcard
fn:Phil Middlemiss
n:Middlemiss;Phil
org:Vision Software, MTS Ltd
email;internet:[EMAIL PROTECTED]
title:Project Leader
tel;work:+64 7 3480001
tel;cell:+64 27 4592648
x-mozilla-html:TRUE
url:http://www.tumonz.co.nz
version:2.1
end:vcard
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi