有些异步I/O请求会被同步处理。。比方说,你要读的内容正好在系统缓存中,那么就可以直接copy到你的缓存中,异步I/O请求就可以同步的处理。。于是,在我们coding的时候,就要把情况考虑周全。。
if (!ReadFile(hFile,
pDataBuf,
dwSizeOfBuffer,
&NumberOfBytesRead,
&osReadOperation )
{
if (GetLastError() != ERROR_IO_PENDING)
{
// Some other error occurred while reading the file.
ErrorReadingFile();
ExitProcess(0);
}
else
// Operation has been queued and
// will complete in the future.
fOverlapped = TRUE;
}
else
// Operation has completed immediately.
fOverlapped = FALSE;
if (fOverlapped)
{
// Wait for the operation to complete before continuing.
// You could do some b