Block a function over several frames

I want to achieve the behaviour observed by Unitys EditorUtility Functions OpenFilePanel, SaveFilePanel and similar which blocks the function from which it is called, while remaining the main thread active and running.

Basically, you call a function from within yours, something happens (like a window popping up), the user interacts with it over several frames, an after he finished that, your function continues. But as he interacts with the windows, the main thread continues processing everything else.

Any idea how they’ve done that?

EDIT:
I guess not THEY have done that, rather then Microsoft themselves: The SaveFilePanel for Example, is probably just a wrapper for SaveFileDialog.
Every EditorUtilitys function thus probably uses a child of CommonDialogue, yielded when called ShowDialogue.

Can any UT Guy confirm that? If it’s so, I’ll probably have to find another way of doing that “Block”, f.E. with delegates/actions passed to the function of code that should be executed after the operation finishes.

with a coroutine?

something like

bool notDone;

IEnumerator Foo(){
 notDone = true;
 //"stops" this function until notDone is set to false
 while(notDone){  
  yield return null;
 }
//code to execute once notDone is false here
}

how you set notDone to false after you start this function is up to you.