避免“(不响应)"在一次处理大量数据时在 Windows 中添加标签 [英] Avoiding "(Not Responding)" label in windows while processing lots of data in one lump

查看:6
本文介绍了避免“(不响应)"在一次处理大量数据时在 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 中添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆