سؤال

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