Mega Code Archive

 
Categories / Delphi / Examples
 

Making loops more effective

Title: Making loops more effective Question: How to make loops so they don''t hold back the application Answer: Often when making loops, that have to run for a long time you forget that when the application closes, it will have some problems due to your loop that hasn't ended. Also you have to tell Windows to update your application. To break your loop when the application do this //For-loop for i:=0 to XYZ do begin if Application.Terminated then Break; //Breaking on Application.Terminate //The rest of the code here end; //While-loop while i=XYZ do begin if Application.Terminated then Break; //Breaking on Application.Terminate //The rest of the code here end; To make Windows update your application in a loop add this. Application.ProcessMessages;