如何让一个循环暂停并正常退出
- Delphi(Pascal) code
在一个循环里面用老这样一个暂停 while not Pause1 do begin if Form_exit = true then Exit; Application.ProcessMessages; end;在FormClose里面用 if Form_exit = False then Form_exit := true;怎么不能退出程序呢?
[解决办法]
窗口关闭是设置Form_exit为True,然后当Pause1为False时跳出while所在的过程?
1、跳出循环的语句是break,exit是退出过程或函数
2、Form_exit、Pause1标记变量的值有没有问题,跟踪一下
[解决办法]
while not Pause1 do
begin
if Form_exit = true then Exit;
Application.ProcessMessages;
end;
要写在线程中可能才可以,主程序中可能有问题,执行完close就结束了