参考: C#多线程 BackgroundWorker类使用小例-WPF程序
WPF ProgressBar进度条
C# backgroundwork的使用方法
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private BackgroundWorker bgworker = new BackgroundWorker(); /// <summary> /// 初始化bgwork /// </summary> private void InitWork() { bgworker.WorkerReportsProgress = true; bgworker.DoWork += new DoWorkEventHandler(DoWork); bgworker.ProgressChanged += new ProgressChangedEventHandler(BgworkChange); } /// <summary> /// 当执行BackgroundWorker.RunWorkerAsync方法时会触发该事件,并且传递DoWorkEventArgs参数 /// </summary> private void DoWork(object sender, DoWorkEventArgs e) { for (int i = 0; i <= 100; i++) { bgworker.ReportProgress(i); Thread.Sleep(10); } } /// <summary> ///改变进度条的值,执行bgworker.ReportProgress时触发 /// </summary> private void BgworkChange(object sender, ProgressChangedEventArgs e) { this.progressBar.Value = e.ProgressPercentage; } private void Button_Click(object sender, RoutedEventArgs e) { InitWork(); bgworker.RunWorkerAsync(); } }