Home > Back-end >  System time delay problem
System time delay problem

Time:10-17

I use the method of time delay 10 seconds

Procedure TForm1. Delay (); Var
NumSec: SmallInt;
StartTime: LongInt;
The begin
StartTime:=GetTickCount;
Repeat
Application. ProcessMessages;
Sleep (1);//to solve the problem of CPU100 %
Until GetTickCount> StartTime + 10000;
end;


Program in the Application. The Terminate; Does not respond, other statements will be response, solve?

CodePudding user response:

Don't understand what problem, what you say does not respond to what is scene?

CodePudding user response:

Application. The Terminate; Haven't been able to perform, or does not respond? The latter to go in and have a look.

CodePudding user response:

Didn't see you where is the code in the Application. The Terminate;

CodePudding user response:

Try this:
Procedure TForm1. Delay (); Var
NumSec: SmallInt;
StartTime: LongInt;
The begin
StartTime:=GetTickCount;
Repeat
Application. ProcessMessages;
Sleep (10);//to solve the problem of CPU100 %
Until (GetTickCount> StartTime + 10000) or Application. Terminated;

end;

CodePudding user response:

Don't know your Delay (); What is called
The Application of the Terminate to Terminate the program, the Close, FormCloseQuery, the Halt will not perform,
Don't respond to your code,

CodePudding user response:

It is good to sleep (10000).

CodePudding user response:

Remember the vintage Pascal there is a Delay in a Crt unit (), can be directly latency, and good miss!
  • Related