Esempio n. 1
0
        public static void PubSubPattern()
        {
            // step3: Create Publisher instance
            var trainSignal = new TrainSignal();

            //step4: add subscribers
            new Car(trainSignal);
            new Car(trainSignal);
            new Car(trainSignal);

            // step5: publish events to subscribers
            trainSignal.HereComesAtrain();
        }
Esempio n. 2
0
 public Car(TrainSignal trainSignal)
 {
     //register events or create invokation list
     trainSignal.TrainIsComing += StopCar;
 }