C# 多线程更新Processbar
来源:互联网 发布:设循环队列用数组 编辑:程序博客网 时间:2024/06/11 23:21
C# 多线程更新Processbar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace temp
{
delegate void SetValueCallback(int value);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(Foo));
t.Start();
}
private void Foo()
{
for (int i = 1; i <= 100; i++)
{
Thread.Sleep(100);
SetProcessBarValue(i);
SetLabelValue(i);
}
}
private void SetLabelValue(int value)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.label1.InvokeRequired)
{
SetValueCallback d = new SetValueCallback(SetLabelValue);
this.Invoke(d, new object[] { value });
}
else
{
this.label1.Text = value.ToString() + '%';
}
}
private void SetProcessBarValue(int value)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.progressBar1.InvokeRequired)
{
SetValueCallback d = new SetValueCallback(SetProcessBarValue);
this.Invoke(d, new object[] { value });
}
else
{
this.progressBar1.Value = value;
}
}
}
}
- C# 多线程更新Processbar
- 多线程更新processbar或输出后台更新前端控件
- C#多线程更新UI
- c# 多线程异步更新UI
- C#多线程以及更新UI
- C# ProcessBar 进度条 最简单 用法 (3句搞定)
- C# 多线程中更新窗体控件
- [教程]C#委托多线程更新UI
- C#控件多线程更新用委托
- android processbar
- ProcessBar使用
- C#多线程更新UI。实时显示工作进程
- C#的Invoke和BeginInvoke、多线程中的界面更新
- C# 通过委托控制进度条以及多线程更新控件
- 请教c#多线程操作更新控件的简便方法
- C#中多线程更新Chart控件与BeginInvoke
- symbian 进度条 processbar
- Android processBar的应用
- PHP-Date()
- iOS实用技巧 - AFNetworking2安全的使用自签证书访问HTTPS
- iOS,初始篇(一)
- 递归 数字排列
- Python 面试题集合
- C# 多线程更新Processbar
- JAVA中获取工程路径的方法
- android常用组件
- IOS 紧急申请情况链接和对应的问题
- LeetCode | Best Time to Buy and Sell Stock II(股票购买抛售问题II)
- Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
- C#里面的三种Timer
- 和父母房不能 挺好的今年特还能见人头费你
- printf如何输出64位整数