예제 #1
0
        static void Main()
        {
            Publisher pub = new Publisher();                   //publisher is the class that causes an event at a set interval
            Subscriber sub = new Subscriber();                 //subscriber subcribes to event notifications and prints a message at each event

            pub.TimeInterval = 1000;              //sets the time-interval in ms.
            sub.Subscribe(pub);

            Console.WriteLine("This event will repeat 20 times");
            pub.Start();
        }
예제 #2
0
 public void Subscribe(Publisher pub)
 {
     pub.RaiseCustomEvent += new Publisher.TimerDelegate(Message);               //the event is attached to the delegate
 }
예제 #3
0
 public void Message(Publisher pub, EventArgs e)
 {
     Console.WriteLine("You have a new message");
 }