diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 917af6db9..4526d99e4 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -312,7 +312,12 @@ epicsShareFunc int epicsShareAPI threadIsSuspended (threadId id) stat = GetExitCodeThread (pParm->handle, &exitCode); if (stat) { - return pParm->isSuspended; + if (exitCode!=STILL_ACTIVE) { + return 1; + } + else { + return pParm->isSuspended; + } } else { return 1; diff --git a/src/libCom/timer/osiTimer.cpp b/src/libCom/timer/osiTimer.cpp index 98863e23f..1216fd0de 100644 --- a/src/libCom/timer/osiTimer.cpp +++ b/src/libCom/timer/osiTimer.cpp @@ -330,6 +330,23 @@ osiTimerQueue::~osiTimerQueue() { osiTimer *pTmr; + this->terminateFlag = true; + this->rescheduleEvent.signal (); + this->exitEvent.wait (0.1); + if ( ! this->exitFlag && ! this->isSuspended () ) { + static const unsigned maxCount = 25; + static const double delay = 0.25; + unsigned count = 0; + printf ("waiting %f seconds for timer queue to shut down", + delay * maxCount); + while ( ! this->exitFlag && ! this->isSuspended () && count < 10) { + this->exitEvent.wait (delay); + printf ("."); + count++; + } + printf ("\n"); + } + this->mutex.lock (); // @@ -347,11 +364,6 @@ osiTimerQueue::~osiTimerQueue() pTmr->curState = osiTimer::stateLimbo; pTmr->destroy (); } - this->terminateFlag = true; - this->rescheduleEvent.signal (); - while (!this->exitFlag) { - this->exitEvent.wait (); - } } //