Beispiel #1
0
        static void Main(string[] args)
        {
            // First, create the CoCar.
            CoCarClass car = new CoCarClass();

            // Make the sink.
            CSharpEventSink sink = new CSharpEventSink();

            // Now hook the events to the correct sink method.
            car.AboutToBlow +=
                new __CoCar_AboutToBlowEventHandler(sink.AboutToBlow);
            car.Exploded +=
                new __CoCar_ExplodedEventHandler(sink.Exploded);

            // Finally, work the car and trigger the events.
            for(int i = 0; i < 20; i++)
                Console.WriteLine("Current speed: {0}", car.SpeedUp());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // First, create the CoCar.
            CoCarClass car = new CoCarClass();

            // Make the sink.
            CSharpEventSink sink = new CSharpEventSink();

            // Now hook the events to the correct sink method.
            car.AboutToBlow +=
                new __CoCar_AboutToBlowEventHandler(sink.AboutToBlow);
            car.Exploded +=
                new __CoCar_ExplodedEventHandler(sink.Exploded);

            // Finally, work the car and trigger the events.
            for (int i = 0; i < 20; i++)
            {
                Console.WriteLine("Current speed: {0}", car.SpeedUp());
            }
        }