protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
        {
            // Creating the event handler that is based on the delegate defined below
            ThresholdReachedEventHandler handler = ThresholdReached;

            if (handler != null)
            {
                // Assigning the arguments that the event handler will give to its subscribing functions
                handler(this, e);
            }
        }
 public void Add(int x)
 {
     total += x;
     if (total >= threshold)
     {
         // Defining arguments of the event that will be fed to the event handler
         ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
         args.Threshold   = threshold;
         args.TimeReached = DateTime.Now;
         // Callin the function containing the event handler
         OnThresholdReached(args);
     }
 }