File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -583,6 +583,10 @@ class WASimClient::Private
583583 return E_TIMEOUT;
584584 }
585585
586+ // bail out if connection was canceled while waiting
587+ if (!runDispatchLoop)
588+ return E_FAIL;
589+
586590 // register server's Connect command event, exit on failure
587591 if FAILED (hr = SimConnectHelper::newClientEvent (hSim, CLI_EVENT_CONNECT, EVENT_NAME_CONNECT)) {
588592 disconnectSimulator ();
@@ -638,12 +642,15 @@ class WASimClient::Private
638642 LOG_DBG << " Shutting down..." ;
639643 disconnectServer (!onQuitEvent);
640644 setStatus (ClientStatus::ShuttingDown);
641- SetEvent (hDispatchStopEvent); // signal thread to exit
642- // d->dispatchThread.join();
643645
644- // check for dispatch loop thread shutdown (this is really just for logging/debug purposes)
645- if (!waitCondition ([&]() { return !runDispatchLoop; }, DISPATCH_LOOP_WAIT_TIME + 100 ))
646- LOG_CRT << " Dispatch loop thread still running!" ;
646+ if (!!hDispatchStopEvent) {
647+ SetEvent (hDispatchStopEvent); // signal thread to exit
648+ // d->dispatchThread.join();
649+
650+ // check for dispatch loop thread shutdown (this is really just for logging/debug purposes)
651+ if (!waitCondition ([&]() { return !runDispatchLoop; }, DISPATCH_LOOP_WAIT_TIME + 100 ))
652+ LOG_CRT << " Dispatch loop thread still running!" ;
653+ }
647654
648655 // reset flags/counters
649656 simConnected = false ;
You can’t perform that action at this time.
0 commit comments