How to wait until a callback function has completed

Thanks, but I have tried that and it doesn’t seem to work. I have a “finished” variable set inside the function and after calling the file opening function go into a wait while this finished variable is not false. The function completes but the wait while never ends and so the code hangs.
I assumed this had something to do with the callback thread not passing back the change in that finished variable.

Or am I misunderstanding what you said?