Why would WaitForSingleObject return WAIT_FAILED

前端 未结 4 1461
生来不讨喜
生来不讨喜 2021-01-13 17:06

MSDN says

If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.

The cod

相关标签:
4条回答
  • 2021-01-13 17:21

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

    0 讨论(0)
  • 2021-01-13 17:27

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

    0 讨论(0)
  • 2021-01-13 17:32

    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

    0 讨论(0)
  • 2021-01-13 17:33

    Passing in a bogus object might cause that.

    0 讨论(0)
提交回复
热议问题