可以用这个方法作,可能不是很好 var iTime:LongInt; begin iTime:=GetTickCount; //处理你的程序 repeat Application.ProcessMessages; until (GetTickCount-iTime)>=LongInt(1000);//一秒 end;
用线程,使用Suspend and terminate方法 在线程中调入数据,并不断检测terminated是否为true! 如是真则中断
private IsExit:Boolean;. . . procedure TForm1.Button1Click(Sender: TObject); begin For i:=0 to Query1.RecordCount-1 do begin application.ProcessMessages ; if IsCancel then break; ........... ........... end; end; procedure TForm1.Button2Click(Sender: TObject); begin isExit:=True; end;
var
iTime:LongInt;
begin
iTime:=GetTickCount;
//处理你的程序
repeat
Application.ProcessMessages;
until (GetTickCount-iTime)>=LongInt(1000);//一秒
end;
在线程中调入数据,并不断检测terminated是否为true! 如是真则中断
IsExit:Boolean;.
.
.
procedure TForm1.Button1Click(Sender: TObject);
begin
For i:=0 to Query1.RecordCount-1 do
begin
application.ProcessMessages ;
if IsCancel then
break;
...........
...........
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
isExit:=True;
end;