I have a solution for such cases like this.
My idea was this:
When i need a cycle that runs independently from its originator
i make a new function that contains the loop. Like this:
Code:
action Whatever() {
  ... prepare the call ...
  myCustomFunction(with, any, parameter)
}

function myCustomFunction(with, any, parameter) {
  while(my_condition_is_true) {
    ... do anything important ...
  }
}


Notice that, in the real life the order of these two function is reversed, so the compiler can work with them.

I handled with this way for example panels, input texts and so on. Just like as you want in your opening post.
Hope this helps.