private void bwImport_DoWork(object sender, DoWorkEventArgs e) { // Insert SizeRun int i = 1; progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = sizeRunToImportList.Count)); foreach (SizeRunModel sizeRun in sizeRunToImportList) { SizeRunController.InsertNew(sizeRun); dgSizeRun.Dispatcher.Invoke((Action)(() => { dgSizeRun.SelectedItem = sizeRun; dgSizeRun.ScrollIntoView(sizeRun); })); Dispatcher.Invoke(new Action(() => { lblStatus.Text = "Importing SizeRun ..."; progressBar.Value = i; })); i++; } }