Exemplo n.º 1
0
 public void Add(int x)
 {
     total += x;
     if (total >= threshold)
     {
         ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
         args.Threshold   = threshold;
         args.TimeReached = DateTime.Now;
         OnThresholdReached(args);
     }
 }
Exemplo n.º 2
0
 //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
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 static void u_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine("User 2 added");
     Console.WriteLine("15 reached");
 }
Exemplo n.º 6
0
 static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine();
 }
Exemplo n.º 7
0
 static void c_ExampleSubscriber(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine("Here in the second subscribed event.");
 }
Exemplo n.º 8
0
 //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);
 }