Esempio n. 1
0
 /// <summary>
 /// 定义烧水方法,调用该方法时,将检测事件是否有方法注册,如果有,则调用该方法
 /// 该方法指示在调用BoilWater方法时,烧水事件被触发
 /// </summary>
 public void BoilWater()
 {
     //该方法用以获取所有绑定至该事件的委托
     for (int i = 0; i <= 100; i++)
     {
         temperature = i;
         if (temperature >= 95)
         {
             //触发烧水事件
             if (BoilEvent != null)
             {
                 BoilEventArgs e = new BoilEventArgs(temperature);
                 BoilEvent(this, e);
             }
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 发出警告方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void MakeAlert(object sender, BoilEventArgs e)
 {
     Console.WriteLine("滴滴滴,水温已经{0}度了,请注意", e.temperature);
 }