visual-c++ - Catch 22 等待外部应用程序完成处理并在完成前意外取消它
问题描述
这是我用于启动外部应用程序并等待它完成的代码的一部分:
DWORD WaitResult;
do
{
WaitResult = MsgWaitForMultipleObjects(1,
// only 1 wait object
&processInformation.hProcess, // worker thread
FALSE, // stop if any
INFINITE, // no timeout
QS_ALLINPUT);
if (WaitResult == WAIT_OBJECT_0 + 1)
{
// Handle windows message
MSG Msg;
while (PeekMessage(&Msg, nullptr, 0, (UINT)-1, PM_REMOVE))
{
TRACE3("%d %d %d\n", Msg.message, Msg.wParam, Msg.lParam);
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
} while (WaitResult != WAIT_OBJECT_0);
ASSERT(WaitResult == WAIT_OBJECT_0);
没关系,直到调用 exe 出现问题导致我的应用程序无限期等待。
我没有给出超时数字,因为被调用的 exe 正在与 Outlook 或 Google 同步日历事件。因此,取决于用户的互联网性能和正在同步的服务器......
有什么方法可以安全地添加一个不会实现实际过程的超时?
解决方案
推荐阅读
- r - R中的子集数据框仅适用于某些值
- html - Swiftsoup 解析未找到所有 HTML 类
- .net - 是否有在 Linux Mint 19.3 上下载和安装 .NET Core 3.1 SDK 的说明?
- java - 如果我的设备上的移动后台数据受到限制,Firebase 身份验证将不起作用
- macos - Mac 终端自动完成提示文件不在当前目录中
- python - 默认值未在 tkinter 单选按钮中设置
- python-3.x - python io.BytesIO处理大内容的问题
- python - 如何在 Python 中通过 ZeroMQ PUB/SUB 从 Raspberry Pi 接收图像?
- python - Python根据多维字典中的值添加值的最佳方法
- node.js - 在 Express 中分离 app.use() 与链式 app.use().use()...