public void Add(int x) { total += x; if (total >= threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }
static void MethodThresholdReached(object sender, ThresholdReachedEventArgs e) { Console.WriteLine(sender); Console.WriteLine($"{e.Threshold} was reached at {e.TimeReached}"); }
protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { EventHandler <ThresholdReachedEventArgs> handler = ThresholdReached; handler?.Invoke(this, e); }