TPL .net 4.0 messageBox 随着时间的推移

发布于 2024-10-07 19:00:01 字数 120 浏览 0 评论 0原文

C# 4.0 中显示 MessageBox(或其他形式)的最佳方式是什么,其中显示直到完成不同方法为止所经过的时间?

我想知道如何在 .net 4.0 中使用 TPL 执行此操作,

感谢您的指导

What is the best way in C# 4.0 to show MessageBox (or other form) in which elapsed time is presented till different method is done?

I would like to know how to do this using TPL in .net 4.0

thanks for any guideness

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪我终i 2024-10-14 19:00:01

我认为您无法使用 MessageBox。但如果您使用的是 WPF,则可以创建一个带有控件的表单,这些控件绑定到实现 INotifyPropertyChanged 的​​数据对象,其中包含要显示的数据(即剩余秒数)。然后,您只需在 UI 线程中将该表单显示为模式对话框,然后在后台线程之一中更新数据对象的值(当然使用 Dispatcher.BeginInvoke() 来确保实际更新得到整理到 UI 线程)。

I don't think you'll be able to use a MessageBox. But if you're using WPF, you could create a form with controls that are bound to a data object implementing INotifyPropertyChanged which contains the data you want to display (i.e., the number of seconds remaining). You would just then display that form as a modal dialog box in the UI thread, and then update the values of the data object in one of your backgrounds threads (using Dispatcher.BeginInvoke() of course to make sure that the actual update gets marshaled to the UI thread).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文