Add ::Sleep(0) in engine loop to unblock PostThreadMessage
Sean Hall committed
Feb 6, 2021 at 16:26 UTC
d5c041befbb60e7bfce14af2eaf1e8c686524209
1 file changed
+6
src/engine/engine.cpp
+6
@@ -776,6 +776,12 @@ static HRESULT RunApplication(
776
}
777
else
778
{
779
+ // When the BA makes a request from its own thread, it's common for the PostThreadMessage in externalengine.cpp
780
+ // to block until this thread waits on something. It's also common for Detect and Plan to never wait on something.
781
+ // In the extreme case, the engine could be elevating in Apply before the Detect call returned to the BA.
782
+ // This helps to avoid that situation, which could be blocking a UI thread.
783
+ ::Sleep(0);
784
+
785
ProcessMessage(pEngineState, &msg);
786
}
787
}