public Subscriber(string iD, Publisher pub) { this.id = iD; // Subscribe to the event using C# 2.0 syntax pub.RaiseCustomEvent += this.HandleCustomEvent; }
public static void Main() { Publisher pub = new Publisher(); Subscriber sub1 = new Subscriber("Somebody", pub); // Call the method that raises the event. pub.PrintOnSecond(1); }