重叠 IO 和 ERROR_IO_INCOMPLETE
我已经重叠 IO 工作了两年了,但我将它与一个新应用程序一起使用,并且它向我抛出了这个错误(当我隐藏主窗体时)。
我已经用谷歌搜索过,但我无法理解该错误的含义以及我应该如何处理它?
有什么想法吗?
我在 NamedPipes 上使用它,并且在调用 GetOverlappedResult 后发生错误
DWORD dwWait = WaitForMultipleObjects(getNumEvents(), m_hEventsArr, FALSE, 500);
//check result. Get correct data
BOOL fSuccess = GetOverlappedResult(data->hPipe, &data->oOverlap, &cbRet, FALSE);
// error happens here
I have had overlapped IO working for 2 years now but ive used it with a new application and its chucking this error at me (when i hide the main form).
I have googled but i fail to understand what the error means and how i should handle it?
Any ideas?
Im using this over NamedPipes and the error happens after calling GetOverlappedResult
DWORD dwWait = WaitForMultipleObjects(getNumEvents(), m_hEventsArr, FALSE, 500);
//check result. Get correct data
BOOL fSuccess = GetOverlappedResult(data->hPipe, &data->oOverlap, &cbRet, FALSE);
// error happens here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ERROR_IO_INCOMPLETE
是一个错误代码,表示 Overlapped 操作仍在进行中;GetOverlappedResult
返回 false,因为操作尚未成功。您有两种选择 - 阻塞和非阻塞:
阻塞直到操作完成:将
GetOverlappedResult
调用更改为:这可确保 Overlapped 操作已完成(即成功或失败) ) 在返回结果之前。
轮询完成:如果操作仍在进行中,您可以从函数返回,并在等待结果的同时执行其他工作:
通常,第二个选项比第一个选项更好,因为它确实如此不会导致您的应用程序停止并等待结果。 (但是,如果代码在单独的线程上运行,则第一个选项可能更可取。)
ERROR_IO_INCOMPLETE
is an error code that means that the Overlapped operation is still in progress;GetOverlappedResult
returns false as the operation hasn't succeeded yet.You have two options - blocking and non-blocking:
Block until the operation completes: change your
GetOverlappedResult
call to:This ensures that the Overlapped operation has completed (i.e. succeeds or fails) before returning the result.
Poll for completion: if the operation is still in progress, you can return from the function, and perform other work while waiting for the result:
Generally, the second option is preferable to the first, as it does not cause your application to stop and wait for a result. (If the code is running on a separate thread, however, the first option may be preferable.)