问题描述
我有一个带有进度条的C#Windows Forms应用程序.我想根据某些方法状态动态地进行处理.我在单独的类中有该方法,并正在为该方法创建一个新线程,并带有一个将方法状态传递给父线程的委托.
I have a C# Windows Forms Application with a progress bar. I want to progress that dynamically based on some method status. I have that method in a separate class, and am creating a new thread for that method, with a delegate to pass the status of the method to the parent thread.
我可以在使用progressbar.Dispatcher
的WPF应用程序中解决相同的情况,但是即使使用System.Threading
命名空间,在Windows Forms应用程序中也没有Dispatcher.
The same situation I am able solve in a WPF application using progressbar.Dispatcher
but in a Windows Forms application there is no Dispatcher, even if I use the System.Threading
namespace.
progressbar.Dispatcher
似乎仅在WPF应用程序中可用.
progressbar.Dispatcher
seems to be available only in a WPF Application.
推荐答案
在Winforms中,可以使用ProgressBar.Invoke或ProgressBar.BeginInvoke从另一个线程更新控件.
In winforms you can use the ProgressBar.Invoke or ProgressBar.BeginInvoke to update the control from another thread.
这篇关于Dispatcher不在C#Windows Forms应用程序上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!