HEvent in OVERLAPPED Win32 Structure

When using asynchronous I / O (or "overlapping" I / O in Win32 java script), we need to deal with the structure OVERLAPPEDand its member hEvent. If the I / O function delays the read or write operation, we get an error code ERROR_IO_PENDING, then we expect the asynchronous operation to be completed using the function WaitForXxxEvent, and then call it GetOverlappedResult.

However, if the I / O operation is completed immediately, we will not receive ERROR_IO_PENDING, and in the read operation our read buffer will be immediately filled. But what about the participant OVERLAPPED::hEvent? Will the alarm state be set? I did not find a clear statement about this.

This question may seem pointless (why deal with an event if I know the operation is already completed?), However I have a library that mimics an overlapping pattern, and I need to have the exact same behavior.


As edgar.holleis pointed out in his comment , Raymond Chen explained this on his blog: http://blogs.msdn.com/b/oldnewthing/archive/2014/02/06/10497096.aspx

If asynchronous I / O completes synchronously, does it mean that hEvent in the OVERLAPPED structure is signaled?

Yes.

/ ( ), . Get­Overlapped­Result/Ex -, ; . HasOverlappedIoC , -, - , : ", , . , !"

, - , . , .

+3
1

, . , , ;)

+2

Source: https://habr.com/ru/post/1738413/


All Articles