在 ATL 中显示后台线程进度的最佳方式?
使用 ATL 时,在不阻塞 UI 的情况下显示后台线程进度(例如,当它搜索文件时)的最佳方法是什么?
我仍然希望能够处理消息,允许使用“取消”按钮,并可能允许用户在搜索发生时继续使用该程序。
When using ATL, what is the best way to display the progress of a background thread (e.g. when it's searching for a file) without blocking the UI?
I still want to be able to process messages, to allow for a Cancel button and to possibly allow the user to continue working with the program while the search happens.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没有具体的 ATL。方法之一是将进度详细信息更新到成员变量中并将消息发布到 GUI 窗口,然后通过从成员变量中提取数据并更新 GUI 来处理消息,例如更新静态和/或进度条。
工作线程伪代码:
Window:
UPD。 真实代码片段,
AddText
在后台线程上调用,:并且 代码处理程序:
这使用自定义类(不是“纯”ATL),但我希望你明白这个想法。
There is no ATL specific here. One of the ways to do is to update progress details into member variable and post a message to GUI window, then handle the message by pulling the data from member variable and updating GUI, such as updating static and/or progress bar.
Worker thread pseudo-code:
Window:
UPD. A real code snippet,
AddText
is called on background thread, :And the code handler:
This uses custom classes (not 'pure' ATL), but I hope you get the idea.