var
ThreadList:TList;
procedure TForm2.BtnTestThreadClick(Sender:TObject);
begin
if ThreadList.LockList.Count<=0 then
begin
try
MyThread:=TTestThread.Create(False);
ThreadList.Add(Self);
except
MyThread.Terminate;
end;
end;
MyThread.Priority:=tpNormal;
MyThread.CtrlEdit[0]:=Edit1 as TEdit;
MyThread.CtrlEdit[1]:=Edit2 as TEdit;
end;
procedure TTestThread.Execute;
begin
try
...
finally
Synchronize(CtrlEditEnabled);
ThreadList.Clear;//有时候单步执行到这里就无法执行下去
with ThreadList.LockList do
begin
try
Pack;
Count:=0;
finally
ThreadList.UnlockList;
end;
end;
end;
end;
谢谢各位大哥大姐了,这个错误我怎么都不理解!
希望能给出个详细点的解释啊!
ThreadList:TList;
procedure TForm2.BtnTestThreadClick(Sender:TObject);
begin
if ThreadList.LockList.Count<=0 then
begin
try
MyThread:=TTestThread.Create(False);
ThreadList.Add(Self);
except
MyThread.Terminate;
end;
end;
MyThread.Priority:=tpNormal;
MyThread.CtrlEdit[0]:=Edit1 as TEdit;
MyThread.CtrlEdit[1]:=Edit2 as TEdit;
end;
procedure TTestThread.Execute;
begin
try
...
finally
Synchronize(CtrlEditEnabled);
ThreadList.Clear;//有时候单步执行到这里就无法执行下去
with ThreadList.LockList do
begin
try
Pack;
Count:=0;
finally
ThreadList.UnlockList;
end;
end;
end;
end;
谢谢各位大哥大姐了,这个错误我怎么都不理解!
希望能给出个详细点的解释啊!
MyThread.CtrlEdit[1]:=Edit2 as TEdit;