In my main dialog I have a function that creates a process and waits for it to finish. It might take up to 15-20 seconds. If I simply wait using WaitForSingleObject my dialog becomes unresponsive.
I want to use a combination of EnableWindow(FALSE), and an internal message loop to make my dialog block, but without looking like the app freezes, the way MessageBox and DoModal do. But I’m not sure how to do that an internal message loop.
Running internal message loop is rather trivial coding.
Something like below is all:
To wait for the process exit, you could use very short(<30ms) timeout
WaitForSingleObjectcall in the message loop. OrMsgWaitForMultipleObjects. OrGetExitCodeProcess.I’d like to recommend another approach.
1) Show new modal popup
2) Start the process in OnInitDialog handler and start a timer
3) Check if the process is still running in OnTimer handler, by
GetExitCodeProcess4) Call EndDialog when the process is no longer running