In my applications, I find the need to have infinite loops, basically repeating a continuous action if another event does not occur, so I do this
while(chkFlag)
{
//do something here which takes around 30 seconds
}
Then in some other case, say the button is pressed to stop the loop I'm doing
chkFlag = false;
Now this works, but the problem is that it does not stop the loop right away, since chkFlag is only checked after the complete loop has completed. So can someone please tell me how I can exit the instantaneouly cycle based on the event.
source
share