Reference: http://cqujsjcyj.iteye.com/blog/380926
I think you may still be a little vague. For example, it is easy to understand that if you have two buttons on your form, a "calculation", a "stop",
If your calculations are intensive or complex, when you click the "Calculate" button, you will find that the "stop" buttons do not respond to your clicks, which means that you cannot stop the calculation process at any time. And if you add application.processmessages to the calculated code, Your program will have a chance to respond to other events.
In a large number of cyclic operations, and do not want to use multi-threading, for the computer in the operation can respond to the user's operation, without destroying the instruction execution. The function is similar to the Doevent method in VB.
Procedure delay (msecs:longint);//delay function, Msecs unit is milliseconds (1 seconds in thousands) var firsttickcount, Now:longint;begin Firsttickcount: = GetTickCount (); repeat application.processmessages; Now: = GetTickCount (), until (Now-firsttickcount >= msecs) or (now < firsttickcount); end;
Application.processmessages usage