private void RefreshScheduledGrabs() { BackgroundWorker worker = new BackgroundWorker(); ObservableCollection<ScheduledGrab> grabs = null; ObservableCollection<GrabTemplate> templates = null; worker.DoWork += (s, dwe) => { var db = new SqLiteDal(); grabs = new ObservableCollection<ScheduledGrab>(db.GetScheduledGrabs(null)); templates = new ObservableCollection<GrabTemplate>(db.GetTemplates()); }; worker.RunWorkerCompleted += (Fs, rwe) => { if (rwe.Error != null) { DialogBox.ShowAlert(this, rwe.Error.Message, "Error"); } else { ScheduledGrabs = grabs; TemplatesProvider.ObjectInstance = templates; } }; worker.RunWorkerAsync(); WPFUtils.WaitForWorker(worker); CommandManager.InvalidateRequerySuggested(); }
private void RefreshTemplates(object sender, RoutedEventArgs e) { List<GrabTemplate> templates = new List<GrabTemplate>(); BackgroundWorker saveWorker = new BackgroundWorker(); saveWorker.DoWork += (s, dwe) => { var db = new SqLiteDal(); templates = db.GetTemplates(); }; saveWorker.RunWorkerCompleted += (Fs, rwe) => { if (rwe.Error != null) { DialogBox.ShowAlert(this, rwe.Error.Message, "Error Saving Job Results"); } else { this.Templates = new ObservableCollection<GrabTemplate>(templates); } }; saveWorker.RunWorkerAsync(); }