What could cause the ResetEvent API to fail?
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:
- the handle being closed by another process or thread prematurely
- passing gobbledy-gook to ResetEvent()
- 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.
精彩评论