Exemple #1
0
        public void PrintGeneratedAnagrams(List <string> anagrams)
        {
            var pub  = new DisplayWithEvents();
            var sub1 = new Subscriber("printToConsole", pub);
            var sub2 = new Subscriber("printToFile", pub);

            Console.WriteLine();
            Console.WriteLine("Generated anagrams: ");
            foreach (var item in anagrams)
            {
                pub.OnRaiseCustomEvent(new CustomEventArgs("Event triggered"), item);
            }
            Console.WriteLine();
        }
Exemple #2
0
 public Subscriber(string id, DisplayWithEvents pub)
 {
     _id = id;
     // Subscribe to the event
     pub.RaiseCustomEvent += HandleCustomEvent;
 }