Example #1
0
 private static void stock_PriceChanged(object sender, PriceChangedEventArgs e)
 {
     if ((e.NewPrice - e.LastPrice) / e.LastPrice > 0.1M)
     {
         Console.WriteLine("Alert, 10% stock price increase! sell sell");
     }
 }
Example #2
0
        private static async void StockPriceChangedEventHandler(object sender, PriceChangedEventArgs e)
        {
            var heavyCalculationsTask = DoHeavyCalculationsAsync();
            await Task.Delay(1000);

            Console.WriteLine("Writing some text to console while heavy calculations are running in a separate thread.");
            var result = await heavyCalculationsTask;

            Console.WriteLine($"Done, result: {result}.");
            Console.WriteLine("Press <ENTER> to exit.");
        }
Example #3
0
 protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     PriceChanged?.Invoke(this, e);
 }