main loop ?
Posted on 2011-05-10
I have used While-Do loops for things that need to finish before anything else happens.
I am trying to use a loop to control a mode of the program. Depending on the mode in the program, a different loop would be run to look for certain conditions. Perhaps this was a bad idea.
It is interesting how a Delphi program can run without any main control loop, or main procedure. I am still adjusting to this. What I am trying to do is have several main procedures. Depending on the mode in the program, a unique main loop would run.
I was thinking it would be neater to have several smaller procedures, instead of putting everything into one big main procedure. The program has unique modes and it's operation is somehwat different in each mode.
What I discovered is that while a While-Do loop in running noting else can happen. The program more or less locks up until the loop is exited. On-Click events for example don't happen. Anything else inthe procedure before or after the loop doesn't happen until the loop is finished. I didn't expect this. I though it would run in parallel. I think I have done that with timer loops.
Is this just a bad programming idea ? Or is there some other type of loop I might use ? How do I make a loop run while everything else is still working ?