예제 #1
0
        public void TestEventBehaviour()
        {
            Console.WriteLine("=== Naive listener (bad) ===");

            EventSoruce source = new EventSoruce();

            NaiveEventListener listener = new NaiveEventListener(source);

            source.Raise();

            Console.WriteLine("Setting listener to null.");
            listener = null;

            TriggerGC();

            source.Raise();

            Console.WriteLine("Setting source to null.");
            source = null;

            TriggerGC();
        }
예제 #2
0
 public NaiveEventListener(EventSoruce source)
 {
     source.MyEvent += OnEvent;
 }