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"); }
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(); }
// Constructors public EventSubscriber(EventPublisher publisher) { // handling the event from the publisher publisher.RaiseEvent += HandleEvent; }
// Constructors public EventSubscriber(EventPublisher publisher) { // handling the event from the publisher publisher.FileWritten += OnFileWrittenCompleted; }