没有测试:
加一个标志就可以了:不过你的代码必须进行处理:
bFlag初始化为False;
if not bFlag then
begin
bFlag:=True;
exit;
end
else
begin
for i:=0 to 1000 do
begin
Application.ProcessMessages;
if bFlag then exit;
//........Insert your code here;
end;
end;
加一个标志就可以了:不过你的代码必须进行处理:
bFlag初始化为False;
if not bFlag then
begin
bFlag:=True;
exit;
end
else
begin
for i:=0 to 1000 do
begin
Application.ProcessMessages;
if bFlag then exit;
//........Insert your code here;
end;
end;
begin
button1.tag:=0;
exit;
end;
begin
button1.tag:=1;
for i:=0 to 1000 do
begin
Application.ProcessMessages;
if button1.tag=0 then exit;
//...insert your code here
end;
end;
設一個標志flag:boolean=false;//是否是第一次!
MproID//這個是第一次線程ID;
…
procedure Mpro
begin
falg:=true;
你要處理的事情
…
flag:=false;
end;
…
form1.button1click(send:Tobject);
begin
if not flag then
創建線程(MPro)
else
begin
利用MproID殺死第一個線程!
創建線程(MPro)
end;
end;
procedure a;
begin
if a=1 then
begin
//your statement
a=2;
end;
end;