????????????????????progressBar????????????
????????
??????1??????progressBar????????????????????????????
??????2?????????????У?????????????????????????????????壬??????н??????????????????????????????????????
???????????????
???????????????£?
???????????????
????using System.Threading;
????????????

 

namespace ProgressBar
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DateTime dt;    //???
private void btnStart_Click(object sender?? EventArgs e)
{
Thread myThread = new Thread(DoData);
myThread.IsBackground = true;
myThread.Start(int.Parse(txtWhileNumber.Text)); //?????
dt = DateTime.Now;  //????????????
}
private delegate void DoDataDelegate(object number);
/// <summary>
/// ???????
/// </summary>
/// <param name="number"></param>
private void DoData(object number)
{
if (progressBar1.InvokeRequired)
{
DoDataDelegate d = DoData;
progressBar1.Invoke(d?? number);
}
else
{
progressBar1.Maximum = (int)number;
for (int i = 0; i < (int)number; i++)
{
progressBar1.Value = i;
Application.DoEvents();
}
MessageBox.Show(DateTime.Now.Subtract(dt).ToString());  //?????????????
}
}
private void btnClear_Click(object sender?? EventArgs e)
{
progressBar1.Value = 0;
}
}
}