Example #1
0
 //Step 5:
 //Define the adding function
 public void Add(int x)
 {
     total += x;
     if (total >= threshold)
     {
         //If the threshold is reached, then raise the event and set the arguments
         ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
         args.Threshold   = threshold;           // Set/Get in the class below
         args.TimeReached = DateTime.Now;        // Set/Get in the class below
         OnThresholdReached(args);
     }
 }
Example #2
0
 //Step 6:
 //Define a function "counter threshold reached" which is subscribed to the event and does something with the data
 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);
 }