这个线程代码是什么问题?怎么在执行线程中退出线程后不能重新开始执行任务了?
procedure TForm1.Button1Click(Sender: TObject);//执行线程中强制退出线程后(Button2Click是退出线程),再次点击这个按钮我想重新计算(非挂起线程)怎么没有反应了.
begin
sListView1.Items.Clear;
mytimerthread:= TMyThread.Create(1);//线程1代码
mytimerthread1:=TMyThread1.Create(1);//线程2代码
end;
procedure TForm1.Button2Click(Sender: TObject);//在计算中强制退出线程
begin
mytimerthread.Suspend;
mytimerthread1.Suspend;
if Assigned(mytimerthread1) then
mytimerthread1.Terminate;
if Assigned(mytimerthread) then
mytimerthread.Terminate;
end;
[解决办法]
Terminate只是改变一个数据成员的值而已。按住Ctrl键,然后点击Terminate,可以跟进去看看它里面到底做了什么。