private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var box = new ProgressBarWindow(); _steps.ForEach(a => a.IsDone = false); var backgroundWorker = new BackgroundWorker { WorkerReportsProgress = true }; backgroundWorker.DoWork += (sender2, e2) => { foreach (var step in _steps) { if (step.IsDone) { continue; } step.IsDone = true; var _currentProgress = Math.Floor(_steps.Count(a => a.IsDone) * 100 / (double)_steps.Count); ProgressBarWindow.SetProgressBarValue(box, _currentProgress, step.Desc); Thread.Sleep(500); } }; backgroundWorker.RunWorkerAsync(); box.ShowDialog2(this); }