Skip to main content

Posts

Showing posts from May, 2013

Publish Subscribe C#

This is a class which holds the information about the event.        public class TimeEventArgs : EventArgs     {         public TimeEventArgs( string currentTime)         {             this .CurrentTime = currentTime;         }         public string CurrentTime;     } This is a Subject class (Publisher) that the other classes will observe. So it publishes a handler so that other observer classes can subscribe to it.     public class Clock     {         public delegate void SecondChangeHandler ( object clock, TimeEventArgs e);         public SecondChangeHandler OnSecondChange; ...