Пример #1
0
        static void Main(string[] args)
        {
            // Publisher of the event
            EventPublisher publisher = new EventPublisher();

            // Subscribers for the event
            EventSubscriber firstSubscriber = new EventSubscriber(publisher);
            //EventSubscriber secondSubcriber = new EventSubscriber(publisher);
            //EventSubscriber thirdSubscriber = new EventSubscriber(publisher);

            // Publisher do some work and after that the event has been raised
            publisher.WriteFile("..//..//", "TestEventHandling.txt");
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Publisher of the event
            EventPublisher publisher = new EventPublisher();

            // Subscribers for the event
            EventSubscriber firstSubscriber = new EventSubscriber(publisher);
            EventSubscriber secondSubcriber = new EventSubscriber(publisher);
            EventSubscriber thirdSubscriber = new EventSubscriber(publisher);

            // Publisher do some work and after that the event has been raised
            publisher.DoSomething();
        }
Пример #3
0
 // Constructors
 public EventSubscriber(EventPublisher publisher)
 {
     // handling the event from the publisher
     publisher.RaiseEvent += HandleEvent;
 }
Пример #4
0
 // Constructors
 public EventSubscriber(EventPublisher publisher)
 {
     // handling the event from the publisher
     publisher.FileWritten += OnFileWrittenCompleted;
 }