procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
Cancel:=False;
for I:=1 to 9000000 do
begin
Application.ProcessMessages;
if Cancel then
break;
Edit1.Text:=IntToStr(I);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Cancel:=True;
end;