【新人求教】第一天上班就遇到难题,有关“进度条控件”和“多线程”同步的 http://www.cnblogs.com/inforasc/archive/2009/10/12/1582110.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void button1_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem((object o) => { for (int i = 1; i <= 100; i++) { this.label1.Invoke(new Action(() => this.label1.Text = i + "%")); this.progressBar1.Invoke(new Action(() => this.progressBar1.Value = i)); } }); ThreadPool.QueueUserWorkItem((object o) => { for (int i = 1; i <= 100; i++) { this.label2.Invoke(new Action(() => this.label2.Text = i + "%")); this.progressBar2.Invoke(new Action(() => this.progressBar2.Value = i)); } }); } 提示:1、Invoke;2、Application.DoEvents(); 线程池 吧 另外有可能会需要从worker thread 调用主界面UI 直接在窗体里定义一组属性在set里把值赋值给进度条控件,不行吗 c# winform委托事件的问题 没分了,跪求SocketAsyncEventArgs服务端如何定时主动给客户端发信息 数组小问题..麻烦请进来一下 如何用C#实现禁用和启用网卡 求助 WF的问题 急!!! 大家好,帮我看看在WCF里面怎么调用窗体好吗? 100分求:web编程高手应具有哪些能力? 一个无从下手的问题(c#) 如何使DataGrid具有XP的样式? winForms问题 求优化,求Linq大神现身。 webbrowser 控件的奇怪问题
private void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem((object o) =>
{
for (int i = 1; i <= 100; i++)
{
this.label1.Invoke(new Action(() => this.label1.Text = i + "%"));
this.progressBar1.Invoke(new Action(() => this.progressBar1.Value = i));
}
}); ThreadPool.QueueUserWorkItem((object o) =>
{
for (int i = 1; i <= 100; i++)
{
this.label2.Invoke(new Action(() => this.label2.Text = i + "%"));
this.progressBar2.Invoke(new Action(() => this.progressBar2.Value = i));
}
});
}
在set里把值赋值给进度条控件,不行吗