创建一个Thread后,Execute方法能否多次执行呢?(不希望反复创建线程)例如: FreeOnTerminate := False; procedure TReconThread.Execute;
begin
inherited; while not Terminated do
begin
//do something
end;
Suspend();
end; 我做了测试,第一次执行Execute后,再次Resume,是不会执行Execute方法的。 是我写得不对,还是本身就不支持这种做法呢? 分不多了,见谅!
begin
inherited; while not Terminated do
begin
//do something
end;
Suspend();
end; 我做了测试,第一次执行Execute后,再次Resume,是不会执行Execute方法的。 是我写得不对,还是本身就不支持这种做法呢? 分不多了,见谅!
解决方案 »
- 大家是否使用包封装数据模块?
- 如何用indy实现可以及时控制的下载?
- delphi有没有设置全部断点,或清楚所有断点的??
- 本人菜鸟。找高手帮忙。急~~~~~~~~
- Error creating cursor handle 是什么错误?
- 导数据问题
- 提问????谁有SUIPack For DelphiBCB V3.96的rar压缩包密码
- 我用quickreport时遇到了这样的问题,那位大虾可以为我解惑?
- delphi中有什么简单制作动画得办法?
- 怎样添加记录?
- 100分进一步挑战:500个DBEdit控件动态条件显示部分并对应查询的数据库字段,具体如下!!!!
- 我们公司是本地公网运营商,想做光缆资源管理系统
begin
//do something finish Suspend();
end;
begin
//do something finish
if not Terminated then//最好还加上这句
Suspend();
end;
begin
Finished := False;
DoMyWork(); if (not Terminated) and Finished then Suspend();
end; procedure DoMyWork()
begin
//do it
Finished := True;
end;
execute是线程的执行体,具体的你可以看vcl中关于thread类及ThreadProc就明白了,而线程启动后就进入execute执行,当前是不会二次进入的。你suspend只是让线程不再获取时间片。