//Raise the event protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { EventHandler <ThresholdReachedEventArgs> handler = ThresholdReached; //The non-generic version will be //EventHandler handler = ThresholdReached; if (handler != null) { handler(this, e); } }
public void Add(int x) { total += x; if (total >= threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }