+ APIRET ulrc;
+ do {
+ ulrc = ::DosWaitEventSem(m_vEvent, ulMilliseconds );
+ switch ( ulrc )
+ {
+ case NO_ERROR:
+ break;
+
+ case ERROR_TIMEOUT:
+ if (ulMilliseconds == SEM_IMMEDIATE_RETURN)
+ return wxSEMA_BUSY;
+ else
+ return wxSEMA_TIMEOUT;
+
+ default:
+ wxLogLastError(_T("DosWaitEventSem(semaphore)"));
+ return wxSEMA_MISC_ERROR;
+ }
+ ulrc = :: DosRequestMutexSem(m_vMutex, ulMilliseconds);
+ switch ( ulrc )
+ {
+ case NO_ERROR:
+ // ok
+ break;
+
+ case ERROR_TIMEOUT:
+ case ERROR_TOO_MANY_SEM_REQUESTS:
+ if (ulMilliseconds == SEM_IMMEDIATE_RETURN)
+ return wxSEMA_BUSY;
+ else
+ return wxSEMA_TIMEOUT;
+
+ default:
+ wxFAIL_MSG(wxT("DosRequestMutexSem(mutex)"));
+ return wxSEMA_MISC_ERROR;
+ }
+ bool OK = false;
+ if (m_count > 0)
+ {
+ m_count--;
+ OK = true;
+ }
+ else
+ {
+ ULONG ulPostCount;
+ ::DosResetEventSem(m_vEvent, &ulPostCount);
+ }
+ ::DosReleaseMutexSem(m_vMutex);
+ if (OK)
+ return wxSEMA_NO_ERROR;
+ } while (ulMilliseconds == SEM_INDEFINITE_WAIT);
+
+ if (ulMilliseconds == SEM_IMMEDIATE_RETURN)
+ return wxSEMA_BUSY;
+ return wxSEMA_TIMEOUT;