开发者

c# while loop to finish current loop before ending

I have a do while loop in my code and I am having it do about 30 lines of code each time within the loop. When it hits the while statement eg. it continues until ESC is pressed, Im not sure but will it complete the current loop or just up to the point where till the button is pressed? Because if all the code in the loop doesnt complete then the file it creates will be corrupted...

So does it complete th开发者_StackOverflow中文版e current loop, if not how can I make it so the while loop will allow it to complete before exiting?


The code will exit where you have the condition check i.e while loop condition - while(somethingTrue), hence it will only break at the start of the while loop code block and not in between.


If the check for the escape key is called within the While(...) block then yes, the loop will finish its current iteration before doing this check and deciding whether or not to loop again. If you're checking for the escape key inside the loop and calling break, then no, the iteration is not guaranteed to finish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜