简体   繁体   中英

Register to receive windows messages when an Win32 event is signaled in MFC

I have a simple MFC dialog app. I would like to do some overlapped I/O. Waiting for the overlapped event handle in a separate thread is a pain. I'm wondering if there is a function call to register a windows message to a waitable handle? Much like how WSAAsyncSelect works, but without the socket and just a generic Win32 waitable handle (event, mutex, pipe, etc).

My environment: Windows XP, Visual Studio 2010

Thanks!

Given your constraints, I'd use RegisterWaitForSingleObject() to register a callback routine that'll be invoked when the object you waiting on is signaled.

The callback function is simple - it merely needs to Post a user defined message to the interested window indicating that the event is signaled.

That said, if you're using ReadFileEx() , WriteFileEx() , or other I/O function that supports a completion callback, you can use that callback to achieve similar functionality.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM