private void btnImportClasses_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MS Access files (*.mdb)|*.mdb"; if (dialog.ShowDialog() == true) { if (dialog.FileName.EndsWith(".mdb")) { try { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, ea) => { var classes = AccessDatabaseHelper.GetClassesFromAccess(dialog.FileName); client.AddClasses(classes); UpdateClassViews(); }; worker.RunWorkerCompleted += (o, ea) => { this.busyIndicator.IsBusy = false; MessageBox.Show("Класовете бяха импортирани успешно"); }; this.busyIndicator.IsBusy = true; worker.RunWorkerAsync(); } catch (Exception ex) { MessageBox.Show("Грешка при импортирането. Класовете не бяха добавени"); } } else { MessageBox.Show("Програмата поддържа само MS Access файлове (.mdb)"); } } }