I need the opportunity to exit loop as soon as my condition is met. It does not make sense, that I need to fully execute my entire body in the ‘While’ loop before I can exit.
The only way I can possibly imagine this happening, is by putting my loop inside a try catch and then a throw to exit, but this is not best practice.
I just tested Break on While and Do While. I get the error description: “Activity can only be placed inside a ForEach”.
In regards to your other solution, the boolean condition would not help me as the condition statement is only considered on each new loop. Thus, when my condition boolean is changed midway through the loop, I still need to finish the remainder of my code inside the body, before the loop acknowledges that I expect it to finish.
What I need is what the Break activity provides for the ForEach. A possibility to exit the loop AS SOON as my condition is met.
I agree that this solution that you presented, Mihai, makes sense for very simple loops. However, it will make for terrible reading/visual representation for more complex processes, where I would then probably need multiple nested if statements.
It is unfortunate that you are unable to change and are limited by Microsoft but from a pure programming point of view the current activity cannot be described as a fully functional While loop.
While I agree that having an actual break would be great, in my experience after you pass the point where nesting/chaining if’s makes sense, it’s better to redesign as a flowchart or even a state machine (depending on transition complexity and other needs).
Both of them have higher memory footprint, but are much more readable in the long run for these kind of situations.
While I agree to a certain extent, the entire point of the while loop is to continuously loop through my body AS LONG as my condition is valid. AS SOON as my condition is invalid I need to exit the loop. Without this possibility it makes it more of a While’ish loop more than an actual While loop.
I want to thank both of you for your solutions and thoughts though. As long as Microsoft limits this functionality work-arounds are needed.