コード例 #1
0
        static void Main(string[] args)
        {
            Car           car           = new Car();
            HighwayPatrol highwayPolice = new HighwayPatrol();

            // Wiring the event handler of the listener to the event
            car.CarSpeedChanged += highwayPolice.HandleWhenExceedSpeed;

            car.Speed = 200;                     // Raise the event
            System.Threading.Thread.Sleep(1000); // Wait for 1 second
            car.Speed = 300;                     // Raise the event again

            System.Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Car car = new Car();
            HighwayPatrol highwayPolice = new HighwayPatrol();

            // Wiring the event handler of the listener to the event
            car.CarSpeedChanged += highwayPolice.HandleWhenExceedSpeed;

            car.Speed = 200; // Raise the event
            System.Threading.Thread.Sleep(1000); // Wait for 1 second
            car.Speed = 300; // Raise the event again

            System.Console.ReadKey();
        }