1/* !!! check comments in original article re: race conditions */
2/* new way to declare event */
3public event EventHandler Updated = delegate { };
4
5protected void UpdatePrice(string tickerSymbol, decimal newPrice, long newVolume)
6{
7 _priceList[tickerSymbol] = newPrice;
8 _volumeList[tickerSymbol] = newVolume;
9
10 Updated(this, new MarketFeedEventArgs(tickerSymbol, newPrice, newVolume));
11}
12
13/* old way to declare event */
14public event EventHandler Updated;
15
16protected void UpdatePrice(string tickerSymbol, decimal newPrice, long newVolume)
17{
18 _priceList[tickerSymbol] = newPrice;
19 _volumeList[tickerSymbol] = newVolume;
20
21 if(Updated != null)
22 Updated(this, new MarketFeedEventArgs(tickerSymbol, newPrice, newVolume));
23}