Exemplo n.º 1
0
        public void CreateAndRaise3()
        {
            Pub3 p3 = new Pub3();

            p3.OnChange += (sender, e) => Console.WriteLine("Event raised: {0}", e.Value);

            p3.Raise();
        }
Exemplo n.º 2
0
        private void UsingEventHandlerWithEventArgs()
        {
            Console.WriteLine("Implementing Event Handler with Event Args, locking and event Property");
            Console.WriteLine("Type applied to Event handler need not extent EventArgs class");
            Pub3 pub = new Pub3();

            pub.OnChange += (sender, e) => Console.WriteLine("Event 1 raised:{0} by {1}", e.Value, sender);
            pub.OnChange += (sender, e) => Console.WriteLine("Event 2 raised:{0} by {1}", e.Value, sender);
            pub.Raise();
            Console.WriteLine("In above example a custom event accessor is used");
            Console.WriteLine("Custom event accessor is like property but it has add and remove blocks instead of get and set;");
        }
Exemplo n.º 3
0
 private void UsingEventHandlerWithEventArgs()
 {
     Console.WriteLine("Implementing Event Handler with Event Args, locking and event Property");
     Console.WriteLine("Type applied to Event handler need not extent EventArgs class");
     Pub3 pub = new Pub3();
     pub.OnChange += (sender, e) => Console.WriteLine("Event 1 raised:{0} by {1}", e.Value, sender);
     pub.OnChange += (sender, e) => Console.WriteLine("Event 2 raised:{0} by {1}", e.Value, sender);
     pub.Raise();
     Console.WriteLine("In above example a custom event accessor is used");
     Console.WriteLine("Custom event accessor is like property but it has add and remove blocks instead of get and set;");
 }