Skip to content

Commit bdddea9

Browse files
authored
[AOT] Fix CPU consumption (#19653)
Wait until object is signaled instead
1 parent 9fb9c6a commit bdddea9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH) :
5454

5555
AlwaysOnTop::~AlwaysOnTop()
5656
{
57+
m_running = false;
58+
5759
if (m_hPinEvent)
5860
{
61+
// Needed to unblock MsgWaitForMultipleObjects one last time
62+
SetEvent(m_hPinEvent);
5963
CloseHandle(m_hPinEvent);
6064
}
61-
62-
m_running = false;
6365
m_thread.join();
6466

6567
CleanUp();
@@ -280,7 +282,11 @@ void AlwaysOnTop::RegisterLLKH()
280282
MSG msg;
281283
while (m_running)
282284
{
283-
DWORD dwEvt = MsgWaitForMultipleObjects(1, &m_hPinEvent, false, 0, QS_ALLINPUT);
285+
DWORD dwEvt = MsgWaitForMultipleObjects(1, &m_hPinEvent, false, INFINITE, QS_ALLINPUT);
286+
if (!m_running)
287+
{
288+
break;
289+
}
284290
switch (dwEvt)
285291
{
286292
case WAIT_OBJECT_0:

0 commit comments

Comments
 (0)