Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#events and observer patternSingle-choice MCQ

Given this event subscription pattern, what happens when the publisher raises the event after `obj` is no longer referenced anywhere else in the application?

public class Publisher { public event EventHandler Tick; public void Raise() => Tick?.Invoke(this, EventArgs.Empty); } var pub = new Publisher(); // long-lived var obj = new Subscriber(); // expected to be short-lived pub.Tick += obj.OnTick; obj = null; // drop the only other reference