Loop -> Wait for user confirmation
-
Good Day Sir/Maam, Whats the best way to temporarily stop a loop and wait for a mouse click on a command button before proceeding? while(True) { //Dothis getch(); } Just like the above code, but this time, not a key press but a click event on a command button. Thanks in advance. :)
-
Good Day Sir/Maam, Whats the best way to temporarily stop a loop and wait for a mouse click on a command button before proceeding? while(True) { //Dothis getch(); } Just like the above code, but this time, not a key press but a click event on a command button. Thanks in advance. :)
-
Hello, I don't know if it's only me, but I don't like such solutions. I would rather set a flag in the method (where you wanted to wait). Than check this flag at the ButtonClick event, and go on with the code. All the best, Martin
-
Thanks for the reply. I need it to make a program that simulates a sorting algorithm, So I need to show each pass so the user can "WATCH" it. :)
-
Good Day Sir/Maam, Whats the best way to temporarily stop a loop and wait for a mouse click on a command button before proceeding? while(True) { //Dothis getch(); } Just like the above code, but this time, not a key press but a click event on a command button. Thanks in advance. :)
You could use a ManualResetEvent or AutoRestEvent. Have the event triggered by the button click.
only two letters away from being an asset
-
Good Day Sir/Maam, Whats the best way to temporarily stop a loop and wait for a mouse click on a command button before proceeding? while(True) { //Dothis getch(); } Just like the above code, but this time, not a key press but a click event on a command button. Thanks in advance. :)
What about: while(True) { while(IsLoopPaused == true) { //Add thread.sleep or doevents code here. } getch() } Then have IsLoopPaused set to true when you want to pause and have your button click event set IsLoopPaused to true.
topcoderjax - Remember, Google is your friend. Try this Custom Google Code Search