using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace jmyd.form
{
public partial class ProgressBarForm : Form
{
public ProgressBarForm()
{
InitializeComponent();
}
private void ProgressBarForm_Shown(object sender, EventArgs e)
{
Thread myThread = new System.Threading.Thread(new ThreadStart(Send));
myThread.IsBackground = true;
myThread.Start();
}
//模拟进度条
private void Send()
{
int i = 0;
while (i <= 100)
{
//显示进度信息
this.ShowPro(i);
if (i == 100)
{
i = 0;
}
i++; //模拟发送多少
Thread.Sleep(500);
}
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.prcBar.Value = value;
this.label1.Text = value + "% Processing...";
}
}
private void myStartingMethod()
{
for (int i = 1; i <= 100; i++)
{
prcBar.Value = i;
}
}
}
}
转: http://www.piaoyi.org/c-sharp/C-ProgressBar.html