Esempio n. 1
0
        public void CreateAndRaise5()
        {
            Pub5 p5 = new Pub5();

            p5.OnChange += (sender, e) => Console.WriteLine("Subscriber 1 called");
            p5.OnChange += (sender, e) => { throw new Exception(); };
            p5.OnChange += (sender, e) => Console.WriteLine("Subscriber 3 called");

            try
            {
                p5.Raise();
            }
            catch (AggregateException ex)
            {
                Console.WriteLine(ex.InnerExceptions.Count);
            }
        }
Esempio n. 2
0
        private void EventsWithExceptionHandling()
        {
            Console.WriteLine("Events in which manual event handler invokers and exception handling to enable all the handlers to get called even after exceptions");
            Pub5 pub = new Pub5();

            pub.OnChange += (sender, e) => Console.WriteLine("Subscriber 1 is called");
            pub.OnChange += (sender, e) => { throw new Exception(); };
            pub.OnChange += (sender, e) => Console.WriteLine("Subscriber 3 is called");
            try
            {
                pub.Raise();
            }
            catch (AggregateException exp)
            {
                Console.WriteLine(exp.InnerExceptions.Count);
            }
        }
 private void EventsWithExceptionHandling()
 {
     Console.WriteLine("Events in which manual event handler invokers and exception handling to enable all the handlers to get called even after exceptions");
     Pub5 pub = new Pub5();
     pub.OnChange += (sender, e) => Console.WriteLine("Subscriber 1 is called");
     pub.OnChange += (sender, e) => { throw new Exception(); };
     pub.OnChange += (sender, e) => Console.WriteLine("Subscriber 3 is called");
     try
     {
         pub.Raise();
     }
     catch(AggregateException exp)
     {
         Console.WriteLine(exp.InnerExceptions.Count);
     }
 }