コード例 #1
0
        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");
            }
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Avsphere/learningCSharp
 static void HandleConditionFailed(object sender, ConditionFailedEventArgs e)
 {
     Console.WriteLine("Condition from object {0} at {1}", sender.GetHashCode(), e.TimeFailed);
 }