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; public void RunClock() { for ( int i = 0; i <= 4; i++) { Thread .Sleep(1000); TimeEventArgs te = new TimeEventArgs ( DateTime .Now.ToString( "HH:mm:ss" )); if (OnSecondChange != null ) {
C#, OOPS, MVC, WCF, Architecture, SQL, Table, Triggers, Script and SQL Server