private void UpdateStockItem(StockExchange stock) { var addedStock = StockDatas.FirstOrDefault(item => item.Symbol == stock.Symbol); if (addedStock != null) { int index = StockDatas.IndexOf(addedStock); StockDatas[index].Price = stock.Price; StockDatas[index].Volume = stock.Volume; StockDatas[index].DateTime = stock.DateTime; } }
private void AddOrUpdateStockExchange(StockExchange stock) { if (StockDatas.Any(item => item.Symbol == stock.Symbol)) { UpdateStockItem(stock); } else { Application.Current.Dispatcher.Invoke(delegate() { StockDatas.Add(stock); }); } }