예제 #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);
     }
 }
예제 #2
0
 static void MethodThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine(sender);
     Console.WriteLine($"{e.Threshold} was reached at {e.TimeReached}");
 }
예제 #3
0
        protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
        {
            EventHandler <ThresholdReachedEventArgs> handler = ThresholdReached;

            handler?.Invoke(this, e);
        }