public void Set(string symbol, double price, double volume) { if (String.IsNullOrEmpty(symbol)) { return;//Can throw invalid argument exception here } var quote = new Quote(symbol, price, volume); _quotes.AddOrUpdate(symbol, quote, (key, oldValue) => quote); }
private void UpdateQuote(string symbol, Quote quote) { if (!_quotes.ContainsKey(symbol)) { _quotes.Add(symbol, quote); } else { _quotes[symbol].UpdateQuote(quote.Price, quote.Volume); } }
public void Set(string symbol, double price, double volume) { if (String.IsNullOrEmpty(symbol)) { return; } var quote = new Quote(symbol, price, volume); if (!quote.IsQuoteValid()) return; _readerWriterLockSlim.EnterWriteLock(); try { UpdateQuote(symbol, quote); } finally { _readerWriterLockSlim.ExitWriteLock(); } }