我用了一下方法延时10秒procedure TForm1.Delay(); var
NumSec:SmallInt;
StartTime:LongInt;
begin
StartTime:= GetTickCount;
repeat
Application.ProcessMessages;
Sleep(1);//能解决CPU100%的问题
until   GetTickCount>StartTime+10000;
end;
程序出现Application.Terminate;不响应,别的语句是会响应的,求解?

解决方案 »

  1.   

    Application.Terminate; 是没执行到, 还是不响应? 后者的话跟进去看看.
      

  2.   

    没看到你代码里哪里用了Application.Terminate;
      

  3.   

    试下这样:
    procedure TForm1.Delay(); var
     NumSec:SmallInt;
     StartTime:LongInt;
     begin
     StartTime:= GetTickCount;
     repeat
     Application.ProcessMessages;
     Sleep(10);//能解决CPU100%的问题
     until (GetTickCount>StartTime+10000) or Application.Terminated;

     end;
      

  4.   

    不清楚你的Delay(); 是什么时候调用的
    Application的Terminate来终止程序的,Close、FormCloseQuery、Halt 都将不会执行,
    不会响应你的代码。
      

  5.   

    sleep(10000)就好了。
      

  6.   

    记得老式Pascal中有个Crt单元里有个Delay(),可直接延时。。好怀念啊!