https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5cee1b95c039d262c680c…
commit 5cee1b95c039d262c680cbf44956f96df70bdcae
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Apr 19 18:44:26 2020 +0200
Commit: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
CommitDate: Mon Apr 20 15:37:19 2020 +0300
[EXPLORER] Keep processing messages while waiting for a startup task
CORE-16909
---
base/shell/explorer/startup.cpp | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/base/shell/explorer/startup.cpp b/base/shell/explorer/startup.cpp
index b8e048df413..f4f064e266a 100644
--- a/base/shell/explorer/startup.cpp
+++ b/base/shell/explorer/startup.cpp
@@ -85,8 +85,37 @@ static int runCmd(LPWSTR cmdline, LPCWSTR dir, BOOL wait, BOOL
minimized)
TRACE("Successfully ran command\n");
if (wait)
- { /* wait for the process to exit */
- WaitForSingleObject(info.hProcess, INFINITE);
+ {
+ HANDLE Handles[] = { info.hProcess };
+ DWORD nCount = _countof(Handles);
+ DWORD dwWait;
+ MSG msg;
+
+ /* wait for the process to exit */
+ for (;;)
+ {
+ /* We need to keep processing messages,
+ otherwise we will hang anything that is trying to send a message to us */
+ dwWait = MsgWaitForMultipleObjects(nCount, Handles, FALSE, INFINITE,
QS_ALLINPUT);
+
+ /* WAIT_OBJECT_0 + nCount signals an event in the message queue,
+ so anything other than that means we are done. */
+ if (dwWait != WAIT_OBJECT_0 + nCount)
+ {
+ if (dwWait >= WAIT_OBJECT_0 && dwWait < WAIT_OBJECT_0 +
nCount)
+ TRACE("Event %u signaled\n", dwWait - WAIT_OBJECT_0);
+ else
+ WARN("Return code: %u\n", dwWait);
+ break;
+ }
+
+ while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+
GetExitCodeProcess(info.hProcess, &exit_code);
}