开发者

WaitForSingleObject Does Not Time Out - C++

开发者 https://www.devze.com 2023-01-30 03:27 出处:网络
My console application calls WaitForSingleObject in the parent thread with a timeout v开发者_如何学运维alue of 5 seconds.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消