开发者

What could cause the ResetEvent API to fail?

开发者 https://www.devze.com 2023-02-16 06:33 出处:网络
I\'m writing a VC++ application.Just for the sake of argument, what could cause the ResetEvent API to 开发者_如何学Pythonfail?The Microsoft documentation is not clear on this.Thanks.Most commonly an i

I'm writing a VC++ application. Just for the sake of argument, what could cause the ResetEvent API to 开发者_如何学Pythonfail? The Microsoft documentation is not clear on this. Thanks.


Most commonly an invalid handle will cause this to fail. An invalid handle, in turn, could result from:

  1. the handle being closed by another process or thread prematurely
  2. passing gobbledy-gook to ResetEvent()
  3. Passing a handle to a thing that isn't an even

Number 1 can often be avoided by creating a duplicate of the handle, by calling DuplicateHandle().

GetLastError() generally will tell you exactly what the problem is, or at least point you in the direction.


Without access to the source of Windows we can only guess. Here's my guess at what could go wrong:

  • The handle is not a valid handle to an event object.
  • The handle does not have the necessary access rights. The documentation states that the handle must have the EVENT_MODIFY_STATE access right.
  • The OS runs out of memory or has some other critical failure.

Reading the WINE source reveals no other explicit failure modes.

0

精彩评论

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