문제

Is there a way to generate a Window message when an Event is set? I want to setup an overlapped I/O operation, so it is not blocking, but I would like not to poll its status. I know I can use a thread, but I would only need it for this operation. There seems like there is a better way.

도움이 되었습니까?

해결책

You can probably do that, but what Windows supports more directly is using MsgWaitForMultipleObjects, which will return when you get a message, or any of the handles you pass (which can be only one) is signaled.

Alternatively, you could use ReadFileEx/WriteFileEx to do the I/O, and use MsgWaitForMultipleObjectsEx. In this case, you specify a completion routine. Execution jumps directly from your call to MsgWaitForMultipleObjectsEx to your completion routine, without your having to look at messages/return values to figure out what happened, then jump to the code to deal with it appropriately.

Either way, you continue to process other Windows messages and deal with completion of the I/O, without polling for I/O completion.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top