TPL .net 4.0 messageBox 随着时间的推移
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您无法使用 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).