Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interrupting loops

Status
Not open for further replies.

acp32

Technical User
Nov 14, 2002
6
GB
A general query.

If I have a button in the GUI that starts off a loop. Is there an elegant method of a second button in the GUI stopping the first loop while it is running.
At the moment I can't click on any other buttons while the loop is tied up.

Any suggestions would be gratefully received.
 
Run the loop in a thread. I dont know how to start a thread in Borland but I am sure someone else here can help with that. As for the second button to be clicked, In your loop for waiting for the thread to finish, also check for if the button has been clicked. Basically when you clikc the button, set a variable and your loop would be

do
{
...
}while(thread_not_done && user_clicked_cancel == false);

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top