void BeginGetQuotes(HashSet <Security> toFetch) { if (_services.Count == 0 || toFetch.Count == 0) { return; } UiDispatcher.BeginInvoke(new Action(() => { OutputPane output = (OutputPane)provider.GetService(typeof(OutputPane)); output.Clear(); output.AppendHeading(Walkabout.Properties.Resources.StockQuoteCaption); })); List <string> batch = new List <string>(); foreach (Security s in toFetch) { if (string.IsNullOrEmpty(s.Symbol)) { continue; // skip it. } batch.Add(s.Symbol); } bool foundService = false; IStockQuoteService service = GetHistoryService(); HistoryDownloader downloader = GetDownloader(service); if (service != null) { downloader.BeginFetchHistory(batch); foundService = true; } service = GetQuoteService(); if (service != null) { foundService = true; if (service.SupportsBatchQuotes) { service.BeginFetchQuotes(batch); } else { foreach (var item in batch) { service.BeginFetchQuote(item); } } } if (!foundService) { AddError(Walkabout.Properties.Resources.ConfigureStockQuoteService); UiDispatcher.BeginInvoke(new Action(UpdateUI)); } }
private HistoryDownloader GetDownloader(IStockQuoteService service) { if (_downloader == null) { _downloader = new HistoryDownloader(service, this._downloadLog); _downloader.Error += OnDownloadError; _downloader.HistoryAvailable += OnHistoryAvailable; } return(_downloader); }