public static void TestBetter() { Console.WriteLine("====== Test Better ======"); var dealer = new CarDealer(); var michael = new Consumer("Michael"); WeakEventManager <CarDealer, CarInfoEventArgs> .AddListener(dealer, michael); dealer.NewCar("Mercedes"); var nick = new Consumer("Nick"); WeakEventManager <CarDealer, CarInfoEventArgs> .AddListener(dealer, nick); dealer.NewCar("Ferrari"); WeakEventManager <CarDealer, CarInfoEventArgs> .RemoveListener(dealer, michael); dealer.NewCar("Toyota"); var dealer_1 = new TestDealer_1(); var listener_1 = new TestListener_1(); WeakEventManager <TestDealer_1, TestArgs_1> .AddListener(dealer_1, listener_1); dealer_1.Test("Hello"); Console.WriteLine("Setting listener to null"); michael = null; listener_1 = null; TriggerGC(); dealer.NewCar("Mercedes"); Console.WriteLine("Setting source to null"); dealer = null; TriggerGC(); }