protected virtual void OnConditionFailed(ConditionFailedEventArgs e) { EventHandler <ConditionFailedEventArgs> handler = ConditionFailed_delegate; if (handler != null) { handler(this, e); } else { Console.WriteLine("OnConditionFailed does not have a handler yet"); } }
public void Eat(int x) { totalEaten += CalculateFoodSize(x); if (totalEaten > foodTillFull) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(totalEaten, DateTime.Now); OnThresholdReached(args); } else { ConditionFailedEventArgs args = new ConditionFailedEventArgs(DateTime.Now); OnConditionFailed(args); } }
static void HandleConditionFailed(object sender, ConditionFailedEventArgs e) { Console.WriteLine("Condition from object {0} at {1}", sender.GetHashCode(), e.TimeFailed); }