public void Add(int x) { total += x; // trigger the event when a's pressed is >= the threshold value if (total >= threshold) { //insert values into event Arguments ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }
//event handler ThesholdReached Event Data to the console static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e) { Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.TimeReached); Environment.Exit(0); }