public IEnumerable <CurrencyPair> GetFirstQuotes(int customerId) { var currencyPairs = new ConcurrentDictionary <string, CurrencyPair>(); var pairNames = _customerInfo.GetListOfPairNames(customerId); // Wait until all quotes will be loaded while (currencyPairs.Count < pairNames.Count) { try { foreach (var p in pairNames) { var r = _ratesService.GetRate(p.Replace("/", string.Empty)); if (r != null) { currencyPairs.AddOrUpdate(r.PairName, r, (key, oldValue) => r); } } } catch (Exception e) { _wrapper.Log.Error(e.Message); Console.WriteLine(e.Message); } } return(currencyPairs.Values.ToList()); }