Exemplo n.º 1
0
 private void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     for (int i = 0; i < _stockPrices.Length; i++)
     {
         var stock = _stockPrices[i];
         if (StockPriceEmulatorUtil.UpdatePrice(ref stock))
         {
             OnStockPriceChangeEvent?.Invoke(this, new StockPriceChangeEventArgs(stock.Symbol, stock.Price));
         }
     }
 }
Exemplo n.º 2
0
 private void StockPricesChangeDispatcher(CancellationToken token)
 {
     while (!token.IsCancellationRequested)
     {
         if (_stockPriceChanges.TryDequeue(out var item))
         {
             OnStockPriceChangeEvent?.Invoke(this, item);
         }
         Thread.Sleep(10);
     }
 }