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--; } }
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(); // } }
private void HeardIt(Metronome m, TickEventArgs e) { System.Console.WriteLine($"HEARD IT AT {e.Time}"); }
public void SendMarketingEmail(Customer c, TickEventArgs e) { Console.WriteLine("Sending a marketing email to a new customer at {0}", e.Time); }