public void CreateAndRaise() { Pub p = new Pub(); p.OnChange += () => Console.WriteLine("Eventraised to method 1"); p.OnChange += () => Console.WriteLine("Eventraised to method 2"); p.Raise(); }
public static void CreateAndRaise() { Pub pop = new Pub(); pop.OnChanged += () => Console.WriteLine("Event raised to method 1"); pop.OnChanged += () => Console.WriteLine("Event raised to method 2"); pop.Raise(); Console.ReadLine(); }
public static void CreateAndRaise() { Pub p = new Pub(); p.OnChange += (sender, e) => Console.WriteLine("Subscriber 1 called"); p.OnChange += (sender, e) => throw new Exception(); p.OnChange += (sender, e) => Console.WriteLine("Subscriber 3 called"); try { p.Raise(); } catch (AggregateException ae) { Console.WriteLine(ae.InnerExceptions.Count); } }