Avoiding quot;(Not Responding)quot; label in windows while processing lots of data in one lump(避免“(不响应)在一次处理大量数据时在 Windows 中添加标签)
问题描述
我偶尔需要处理来自网络外的一个包的大量数据,这需要足够长的时间,以至于当用户尝试与应用程序窗口交互时,会将(未响应)"字符串添加到窗口标题中.我知道这是因为处理是在处理消息的调用中完成的(在堆栈的某个位置),因此阻塞了消息泵.我也知道处理这个问题的理想方法是在一个单独的线程中异步处理数据,以便泵可以继续运行,但是这是一个大型桌面应用程序,它从头到脚都是单线程的,可以安全地关闭这个处理在我们的时间范围内是不可行的.
I occasionally need to process a large amount of data from one package off the network, which takes sufficiently long that when the user tries to interact with the application windows adds the "(Not Responding)" string to the window title. I am aware this is because the processing is being done within a call to handle a message (some way up the stack) and therefore is blocking the message pump. I'm also aware the ideal way to deal with this is to process the data asynchronously in a separate thread so the pump can continue running, however this is a LARGE desktop application which is single threaded from top to toe and safely spinning this processing off is not feasible in our time frame.
因此,考虑到这一点,有没有一种方法可以通过告诉 Windows 我的应用程序之前将繁忙我开始工作?我相信在响应关闭请求时有一些类似的东西,可以继续要求窗口更多时间以避免它宣称您没有及时关闭"
So with that in mind, is there by any chance a way I can at least avoid the "not responding" moniker (which to most users reads as "has crashed") by telling windows my application is about to be busy before I begin the work? I believe there is something along these lines when responding to a request to close, one can keep asking windows for more time to avoid it proclaiming that your not "closing in a timely fashion"
我应该添加这是一个 C++ MFC 应用程序.
I should add this is a C++ MFC application.
推荐答案
我不认为 Windows API 可以帮助你.
I don't think the Windows API can help you here.
或者,如何显示一个带有进度条的对话框并使其在单独的线程中运行?
Alternatively, how about showing a dialog box with a progress bar and make it run in a separate thread?
对话框上的此操作可能需要半小时"之类的文字也可能合适.
A text like "This operation may take half an hour" on the dialog box may be appropriate too.
这篇关于避免“(不响应)"在一次处理大量数据时在 Windows 中添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:避免“(不响应)"在一次处理大量数据时在 Windows 中添加标签
基础教程推荐
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01