private void btnUpdate_Click(object sender, EventArgs e)
{
bgWorker.RunWorkerAsync();
}
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
BackUpDatabase.BackUp(this.txtPath.Text);
for (int i = 0; i <= 100; i++)
{
// Report progress to 'UI' thread
bgWorker.ReportProgress(i);
// Simulate long task
System.Threading.Thread.Sleep(100);
}
}
private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
lblProgress.Text = String.Format("Progress: {0} %", e.ProgressPercentage);
}
该代码正在运行,但我怀疑进度不是确切的时间过程。我在这里错过了什么吗?