using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WinConst
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
this.progressBar1.Minimum = 1;
this.progressBar1.Maximum = 100;
this.progressBar1.Value = 1;
//this.bgw.WorkerReportsProgress = true;
//this.bgw.ProgressChanged+=new ProgressChangedEventHandler(bgw_ProgressChanged);
this.bgw.DoWork+=new DoWorkEventHandler(bgw_DoWork);
}
private void Run()
{
int tem = 1;
while (tem <= 100)
{
bgw.ReportProgress(tem++);
}
List<string> names = new List<string>(){ "ganquangfu", "ligang", "huanghejun" };
}
private void bgw_DoWork(object sender, DoWorkEventArgs e)
{
int tem = 1;
while (tem <= 100)
{
this.progressBar1.Invoke((Action)(() => this.progressBar1.Value = tem++));
}
}
private void bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
//this.progressBar1.Invoke((Action)(() => this.progressBar1.Value = e.ProgressPercentage));
this.progressBar1.Value = e.ProgressPercentage;
}
private void button1_Click(object sender, EventArgs e)
{
new Thread(new ThreadStart((Action)(()=>{this.bgw.RunWorkerAsync();}))).Start();
}
private void Form3_Load(object sender, EventArgs e)
{
}
}
}