Question

I have some problems with controlling a while loop inside an event structure. Say I have an iterative procedure and I want to stop the iterations during run-time (say to check out the results).

 while(resid > 1e-10 )
{

for (int iter = 0;iter < 1000;iter++)
{
// some thing //
}

}

I have 3 buttons ("Start Running, Stop Running, Quit Program"). When the while loop is running, it should be possible to stop the running by clicking on "Stop Running", but this does not work.

I am not saying it has to be buttons but it could be a console app and the termination is done by writing something on the console.

Has anyone an idea on it can be implemented?

Thanks a lot and best regards, Mohammed

Was it helpful?

Solution

You need to check for "Button was pressed" inside the loop and then break out of the loop if it was detected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top