void worker_DoWork(object sender, DoWorkEventArgs e) { for (int i = 0; i < mvm.Employes.Count(); i++) { mvm.GeneralSalary(sender, e, mvm.Employes[i].Id); (sender as BackgroundWorker).ReportProgress((i + 1) * (100 / mvm.Employes.Count())); Thread.Sleep(250); } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("All salaries successfully updated.", "Notification"); App.Current.Dispatcher.Invoke((Action) delegate { ManagerWindow window = new ManagerWindow(); window.Show(); Close(); }); }