Dispatcher不在C#Windows Forms应用程序上 [英] Dispatcher is not coming on C# Windows Forms Application

查看:124
本文介绍了Dispatcher不在C#Windows Forms应用程序上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有进度条的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应用程序上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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