public void Add(int x) { total += x; if (total >= threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }
//adds input int to the total public void Add(int x) { total += x; if (total >= threshold) //check is total is at threshhold { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); //create a class instance args.Threshold = threshold; //assign the number to the instance variable args.TimeReached = DateTime.Now; //give a time for reaching hte threshhold OnThresholdReached(args); //send the instance to the event handler method } }
public void Add(int x) { total += x; if (total > threshold) { NameReachedEventArgs args1 = new NameReachedEventArgs(); args1.Name = "Diana"; args1.Surname = "Zheltok"; OnNameReached(args1); } if (total == threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }
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); }
static void u_ThresholdReached(object sender, ThresholdReachedEventArgs e) { Console.WriteLine("User 2 added"); Console.WriteLine("15 reached"); }
static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e) { Console.WriteLine(); }
static void c_ExampleSubscriber(object sender, ThresholdReachedEventArgs e) { Console.WriteLine("Here in the second subscribed event."); }
//this method is assigned to teh C class ThresholdReached EventHandler static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e) { //tell what the threshhold was and at what time it was reached Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.TimeReached); //Environment.Exit(0); }