예제 #1
0
파일: FireEventTest.cs 프로젝트: nyet/nyet
        public static void Main()
        {
            // Create an instance of the class that will be firing an event.
            FireAlarm myFireAlarm = new FireAlarm();

            // Create an instance of the class that will be handling the event. Note that
            // it receives the class that will fire the event as a parameter.
            FireHandlerClass myFireHandler = new FireHandlerClass(myFireAlarm);

            //use our class to raise a few events and watch them get handled
            myFireAlarm.ActivateFireAlarm("Kitchen", 3);
            myFireAlarm.ActivateFireAlarm("Study", 1);
            myFireAlarm.ActivateFireAlarm("Porch", 5);

            return;
        }
예제 #2
0
파일: FireEventTest.cs 프로젝트: nyet/nyet
 // Create a FireAlarm to handle and raise the fire events.
 public FireHandlerClass(FireAlarm fireAlarm)
 {
     // Add a delegate containing the ExtinguishFire function to the class'
     // event so that when FireAlarm is raised, it will subsequently execute
     // ExtinguishFire.
     fireAlarm.FireEvent += new FireAlarm.FireEventHandler(ExtinguishFire);
 }