Beispiel #1
0
        /// <summary>
        /// Method for calculation of the Stock
        /// </summary>
        /// <param name="obj"></param>
        private static void Update(object obj)
        {
            //casting from object class
            Stock s = (Stock)obj;

            // randomly generated number should be updated here
            s.currentValue += s.rnd.Next(1, s.maximumChange);

            //update the numberchanges
            s.numberchanges++;

            //Absolute difference of currentvalue and initialvalue
            double difference = Math.Abs(s.currentValue - s.initialValue);

            if (difference > s.threshold)
            {
                //if the difference is greater than threshold then raise event
                StockNotificationArgs args = new StockNotificationArgs();
                args.Stockname     = s.stockName;
                args.CurrentValue  = s.currentValue;
                args.MaximumChange = s.maximumChange;
                s.Thresholdreached(args);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Method for invoking the event
 /// </summary>
 /// <param name="e">Eventargs object</param>
 public void Thresholdreached(StockNotificationArgs e)
 {
     thresholdreached.Invoke(e.Stockname, e.CurrentValue, e.MaximumChange);
 }