WaitForSingleObject Does Not Time Out - C++
My console application calls WaitForSingleObject
in the parent thread with a timeout v开发者_如何学运维alue of 5 seconds.
dwObjectWaitState = ::WaitForSingleObject( s_hRxDataEvent, 50000L );
After configuring the physical environment (i.e. no code changes), so that the event will never get signaled, I set a breakpoint at the following line, and run the application. The PC never gets to the breakpoint. s_hRxDataEvent
is a valid event handle that is normally set in a child thread. The application works great when the physical environment is configured as expected. Why doesn't the function time out? Thanks.
The timeout is in milliseconds. 50000 is 50 seconds, not 5 seconds.
Note that you have an extra zero there.
50000L milliseconds = 50 seconds.
The timeout value for WaitForSingleObject
is specified in milliseconds, so 50000L means 50 seconds, not 5 seconds.
精彩评论