Get out of infinite loop question!
-
Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.
-
Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.
http://www.codeproject.com/threads/usingworkerthreads.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.
Use a worker thread. If you don;t thread the application, then the reason you're locking the program up is because the Message Loop never has the chance to run, and therefore the button press is never noticed. Use a thread for the user interface, and one to do the loop.
-
Hi all, I am writing a program that continuously stores data from an external memory. while(isConnected) { // Do stuff over here }// end while However, when it runs, it takes all the memory (program is not responded). I have another button (Stop) to call method to set isConnected to False in order to get out of the loop. However, I didn't even have a chance to hit that button because the program is freezed. Any suggestions? Thanks.