예제 #1
0
 public void Subscribe(Countdown countdown)
 {
     countdown.CountdownComplete += delegate(object c, CountdownInfoEventArgs countdownInfo)
     {
         var timeInSeconds = countdownInfo.TimeInSeconds;
         var message = countdownInfo.Message;
         System.Console.WriteLine("Countdown completed in {0} seconds: '{1}'", timeInSeconds, message);
     };
 }
예제 #2
0
파일: Program.cs 프로젝트: JackMorris/LCS3
        static void Main(string[] args)
        {
            Countdown countdown = new Countdown(10, "Hello, world!");

            CountdownDisplay countdownDisplay = new CountdownDisplay();
            countdownDisplay.Subscribe(countdown);
            CountdownDisplay countdownDisplay2 = new CountdownDisplay();
            countdownDisplay2.Subscribe(countdown);

            countdown.Start();
        }