private void SaveUICache(NewsgroupAnswersCollection groups) { var ui = new UICache(); ui.NewsgroupAnswers = groups; ui.Save(GetFileName()); // force reloading of list... _groupView = null; _groupViewSource = null; firstTime = true; RaisePropertyChanged("Newsgroups"); }
private void CmdLoadNewsgroupListClick(object sender, RoutedEventArgs e) { cmdLoadNewsgroupList.IsEnabled = false; ThreadPool.QueueUserWorkItem(delegate(object o) { var t = o as MainWindow; try { var idx = 0; Traces.Main_TraceEvent(TraceEventType.Information, 1, "Start prefetching newsgroup list"); SetPrefetchInfo(t, "Start prefetching newsgroup list", false); var groups = t._forumsDataSource.PrefetchNewsgroupList( p => SetPrefetchInfo(t, string.Format("Group {0}: {1}", ++idx, p.GroupName), false)); SetPrefetchInfo(t, string.Format("DONE: ({0} newsgroups)", idx), true); Traces.Main_TraceEvent(TraceEventType.Information, 1, "Prefetching DONE; {0} newsgroups", idx); if ((groups != null) && (groups.Count > 0)) { // Save UI-Cache and refresh if (!t.Dispatcher.CheckAccess()) { t.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { var uic = new NewsgroupAnswersCollection(); uic.AddRange(groups.Select(p => new NewsgroupAnswers() { Name = p.GroupName }).OrderBy(p2 => p2.Name, StringComparer.InvariantCultureIgnoreCase) ); SaveUICache(uic); })); } } } catch (Exception exp) { SetPrefetchInfo(t, string.Format("Exception: {0}", NNTPServer.Traces.ExceptionToString(exp)), true); } }, this); }