为什么我不能运行两次或更多次我的线程。 (代码中的第二个调用不起作用)。在程序"执行"没有循环,表现得好像一直在工作。
procedure TMyThread.Execute;
begin
do_something();
end;
procedure TForm1.Do;
var DrawerA:TMyThread;
begin
DrawerA:=TMyThread.Create(True);
DrawerA.Priority:=tpNormal;
DrawerA.FreeOnTerminate:=False;
DrawerA.Start;
DrawerA.WaitFor;
DrawerA.Start;
DrawerA.WaitFor;
{
if( Not DrawerA.Suspended) then DrawerA.Start
else DrawerA.Resume;
}
端;
答案 0 :(得分:0)
线程执行其线程过程然后终止。如果您希望线程执行多个任务,那么您需要将迭代构建到线程过程中。