//模拟进度条
private void Send()
{
int i = 0;
while (i <= 100)
{
//显示进度信息
this.ShowPro(i);
i++; //模拟发送多少
Thread.Sleep(100);
}
Thread.CurrentThread.Abort();
}
private delegate void ProgressBarShow(int i); private void ShowPro(int value)
{
if (this.InvokeRequired)
{
this.Invoke(new ProgressBarShow(ShowPro), value);
}
else
{
this.progressBar1.Value = value;
this.label1.Text = value + "% Processing...";
}
}
private void Form1_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(Send)); //模拟进度条
thread.IsBackground = true;
thread.Start();
}