private async Task GetYahooRefrencesAsync() { await Task.Factory.StartNew(async() => { if (YahooReferences.Count != 0 || this.IsBusy) { return; } await System.Windows.Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { this.IsBusy = true; })); List <BaseSearchResult> results = new List <BaseSearchResult>(); var yahooDataProvider = new YahooDataProvider(_fqdn, results, _cancellationToken, _domainParser); await yahooDataProvider.LoadMoreItemsAsync(Int32.MaxValue); var items = results.Where((x) => x.Source.Equals("Yahoo")); var fdqn = _fqdn.ToLowerInvariant(); foreach (var item in items) { var domain = item.Domains.FirstOrDefault(x => x.Address.ToLowerInvariant().Equals(fdqn)); if (domain != null) { var backRefrence = new YahooBackLink(); backRefrence.Source = "Yahoo"; backRefrence.SourceAddress = item.SourceAddress; backRefrence.FullAddress = domain.FullAddress; backRefrence.SearchResult = (YahooSearchResult)item; await System.Windows.Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { YahooReferences.Add(backRefrence); })); } } await System.Windows.Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { this.IsBusy = false; IsYahooReferencesAvailable = YahooReferences.Count > 0 ? true : false; if (IsYahooReferencesAvailable) { this.IsBackLinkCountVisible = true; this.BackLinkCount = YahooReferences.Count.ToString("N0"); } })); }); }
public YahooDataProviderConfigDlg(StockDictionary stockDico) { InitializeComponent(); this.dataProvider = new YahooDataProvider(); this.stockDictionary = stockDico; this.step1GroupBox.Enabled = true; this.step2GroupBox.Enabled = false; // Init group combo box this.groupComboBox.Items.Clear(); this.groupComboBox.Items.AddRange(stockDico.GetValidGroupNames().ToArray()); string[] userGroups = { "USER1", "USER2", "USER3" }; foreach (string group in userGroups) { if (!this.groupComboBox.Items.Contains(group)) { this.groupComboBox.Items.Add(group); } } this.groupComboBox.SelectedItem = userGroups[0]; // Init personal list view string fileName = Settings.Default.RootFolder + this.dataProvider.UserConfigFileName; if (File.Exists(fileName)) { using (StreamReader sr = new StreamReader(fileName, true)) { string line; while (!sr.EndOfStream) { line = sr.ReadLine(); if (!line.StartsWith("#")) { string[] row = line.Split(','); ListViewItem viewItem = new ListViewItem(row[0]); viewItem.SubItems.Add(row[1]); viewItem.SubItems.Add(row[2]); this.personalListView.Items.Add(viewItem); } } } } needRestart = false; }