diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index cf2353b615..7c5a377d5e 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -267,7 +267,16 @@ public: bool IsOk() const { return m_semaphore != NULL; } wxSemaError Wait() { return WaitTimeout(INFINITE); } - wxSemaError TryWait() { return WaitTimeout(0); } + + wxSemaError TryWait() + { + wxSemaError rc = WaitTimeout(0); + if ( rc == wxSEMA_TIMEOUT ) + rc = wxSEMA_BUSY; + + return rc; + } + wxSemaError WaitTimeout(unsigned long milliseconds); wxSemaError Post(); @@ -321,7 +330,7 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds) return wxSEMA_NO_ERROR; case WAIT_TIMEOUT: - return wxSEMA_BUSY; + return wxSEMA_TIMEOUT; default: wxLogLastError(_T("WaitForSingleObject(semaphore)")); diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 89bc5109f7..113c85a3b2 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -532,8 +532,17 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds) return wxSEMA_TIMEOUT; } - if ( m_cond.WaitTimeout(remainingTime) != wxCOND_NO_ERROR ) - return wxSEMA_MISC_ERROR; + switch ( m_cond.WaitTimeout(remainingTime) ) + { + case wxCOND_TIMEOUT: + return wxSEMA_TIMEOUT; + + default: + return wxSEMA_MISC_ERROR; + + case wxCOND_NO_ERROR: + ; + } } m_count--;