Why would WaitForSingleObject return WAIT_FAILED

耗尽温柔 提交于 2019-12-01 07:00:33

If you lack the SYNCHRONIZE privilege on the object, then you cannot wait. WAIT_FAILED will be returned.

Passing in a bogus object might cause that.

Closing a handle while the handle is being waited on can also cause undefined behaviour.

I got WAIT_FAILED from WaitForMultipleObjects when passing in an array of thread handles as one of them was a pseudo handle. As ever the immortal Raymond Chen explained, and provided the fix: https://blogs.msdn.microsoft.com/oldnewthing/20141015-00/?p=43843

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!