Click here to Skip to main content
15,919,500 members

Comments by Member 10624320 (Top 1 by date)

Member 10624320 30-Jun-15 12:42pm View    
Thanks Sergey for the reply. I'm sorry I didn't put the question properly. My worker thread is supposed to be handling certain asynchronous events (//do work part). In my present case, I know for sure that no events aren't coming. In my main thread, I'm setting m_bShutdown to true and signaling the m_cEvent to notify the worker thread to exit. Normally, the thread ends gracefully and my WaitForSingleObject returns immediately. But some times, I get a WAIT_TIMEOUT even though I know for sure that my worker thread isn't processing any events.

In my main thread, I'm waiting for the worker thread (m_EventHandler) to exit gracefully. It happens most of the time, but of late it's failing intermittently. I read somewhere that the worker thread can terminate too quickly causing this to happen. But I've set m_bAutoDelete to FALSE, so even if the thread function terminates, I'd be waiting on a valid handle in the main thread.