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(); }
public NaiveEventListener(EventSoruce source) { source.MyEvent += OnEvent; }