var Interrupt:boolean;
procedure TForm1.Button5Click(Sender: TObject);
begin
memo1.Lines.Add('Button5Click OK');
Interrupt:=true;
end;
procedure TForm1.Button6Click(Sender: TObject);
var i,j,n:integer;
begin
Interrupt:=false;
for i:=0 to 10000 do
for j:=0 to 10000 do
begin
inc(n);
Application.ProcessMessages;
if Interrupt then
begin
memo1.Lines.Add('Interrupt OK');
exit;
end;
end;
memo1.Lines.Add('Button6Click OK');
end;
博客给出两段代码,一段是按钮 Button5 点击事件,点击后在 memo1 中添加信息并将 Interrupt 设为 true;另一段是按钮 Button6 点击事件,进行嵌套循环,若 Interrupt 为 true 则中断循环并在 memo1 中添加信息。

776

被折叠的 条评论
为什么被折叠?



