Example #1
0
        private static void Escenario1()
        {
            Publisher g  = new Publisher("Big Generator");
            Suscriber s1 = new Suscriber("Suscriber1");

            g.NewNumberEvent += s1.MyEventHandler;

            Suscriber s2 = new Suscriber("Suscriber2");

            g.NewNumberEvent += s2.MyEventHandler;
            g.Publish();
        }
Example #2
0
        static void Main(string[] args)
        {
            Publisher g  = new Publisher("Big Generator");
            Suscriber s1 = new Suscriber("Suscriber1");

            g.GeneratingNumberEvent += s1.MyEventHandler;
            Suscriber s2 = new Suscriber("Suscriber2");

            g.GeneratingNumberEvent += s2.MyEventHandler;

            g.Run();
            g.GeneratingNumberEvent -= s2.MyEventHandler;
            g.Run();
        }
Example #3
0
        private static void Escenario1()
        {
            Publisher g  = new Publisher("Big Generator");
            Suscriber s1 = new Suscriber("Suscriber1");

            g.NewNumberEvent += s1.MyEventHandlerAsync;

            Suscriber s2 = new Suscriber("Suscriber2");

            g.NewNumberEvent += s2.MyEventHandlerAsync;

            g.Publish();
            // Espero un rato para que terminen los eventHandlers asincronicos
            Thread.Sleep(10000);
        }
Example #4
0
        static void Main(string[] args)
        {
            Publisher g  = new Publisher("Big Generator");
            Suscriber s1 = new Suscriber("Suscriber1");

            g.GeneratingNumberEvent += s1.MyEventHandler;
            Suscriber s2 = new Suscriber("Suscriber2");

            g.GeneratingNumberEvent += s2.MyEventHandler;

            g.Run();
            Console.WriteLine("----- Suscriber2 se desuscribe ----");
            g.GeneratingNumberEvent -= s2.MyEventHandler;
            g.Run();
        }
Example #5
0
        private static void Escenario1()
        {
            Publisher g  = new Publisher("Big Generator");
            Suscriber s1 = new Suscriber("Suscriber1");

            g.GeneratingNumber += s1.MyEventHandler;
            Suscriber s2 = new Suscriber("Suscriber2");

            g.GeneratingNumber += s2.MyEventHandler;

            g.GenerateNumbers();

            Console.WriteLine("\n");
            g.GeneratingNumber -= s2.MyEventHandler;
            g.GenerateNumbers();
        }