【发布时间】:2010-08-09 17:06:40
【问题描述】:
程序正常运行了几分钟,然后 ReadFile 开始失败,错误代码为 ERROR_WORKING_SET_QUOTA。
我正在使用带有重叠 I/O 的 ReadFile,如下所示:
while (continueReading)
{
BOOL bSuccess = ReadFile(deviceHandle, pReadBuf, length,
&bytesRead, readOverlappedPtr);
waitVal = WaitForMultipleObjects(
(sizeof(eventsToWaitFor)/sizeof(eventsToWaitFor[0])),
eventsToWaitFor, FALSE, INFINITE);
if (waitVal == WAIT_OBJECT_0) {
// do stuff
} else if (waitVal == WAIT_OBJECT_0 + 1) {
// do stuff
} else if (waitVal == WAIT_OBJECT_0 + 2) {
// complete the read
bSuccess = GetOverlappedResult(deviceHandle, &readOverlapped,
&bytesRead, FALSE);
if (!bSuccess) {
errorCode = GetLastError();
printf("ReadFile error=%d\n", errorCode);
}
}
}
为什么会出现这个错误?
【问题讨论】:
标签: winapi readfile overlapped-io