Example #1
0
        public void Start()
        {
            int count = 5;

            while (count > 0)
            {
                System.Threading.Thread.Sleep(1000);
                if (Tick != null)
                {
                    TickEventArgs e = new TickEventArgs();
                    e.Time = DateTime.Now;
                    Tick(this, e);
                }
                count--;
            }
        }
Example #2
0
 public void SubscribeEmail()
 {
     // phải kiểm tra xem có ai lắng nghe sự kiện không
     if (OnEmailSubscription != null)
     {
         // phát sự kiện
         var e = new TickEventArgs()
         {
             Time = DateTime.Now
         };
         OnEmailSubscription.Invoke(this, e);
     }
     // một cách khác để gọi
     // var del = OnEmailSubscription as CustomerRegistrationHandler;
     // if (del != null){
     //     del();
     // }
 }
Example #3
0
 private void HeardIt(Metronome m, TickEventArgs e)
 {
     System.Console.WriteLine($"HEARD IT AT {e.Time}");
 }
Example #4
0
 public void SendMarketingEmail(Customer c, TickEventArgs e)
 {
     Console.WriteLine("Sending a marketing email to a new customer at {0}", e.Time);
 }