Ejemplo n.º 1
0
            // Test the ListWithChangedEvent class.
            public static void Main()
            {
                // Create a new list.
                ListWithChangedEvent list = new ListWithChangedEvent();

                // Create a class that listens to the list's change event.
                EventListener listener = new EventListener(list);

                // Add and remove items from the list.
                list.Add("item 1");
                list.Clear();
                listener.Detach();
            }
Ejemplo n.º 2
0
 public ClassWithEvent()
 {
     EventList = new ListWithChangedEvent();
 }
Ejemplo n.º 3
0
 public void Detach()
 {
     // Detach the event and delete the list
     List.Changed -= new ChangedEventHandler(ListChanged);
     List          = null;
 }
Ejemplo n.º 4
0
 public EventListener(ListWithChangedEvent list)
 {
     List = list;
     // Add "ListChanged" to the Changed event on "List".
     List.Changed += new ChangedEventHandler(ListChanged);
 }