Quick question. Let's say that I have a class implemented as shown below.
class Subscriber { private Publisher publisher = new Publisher; public Subscriber() { publisher.SomeEvent += new EventHandler(OnEventFired); } private void OnEventFired(object sender, EventArgs e) { } }
And somewhere in the program, I have a method that looks like this:
public void DoSomething() { Subscriber subscriber = new Subscriber(); }
Can this be expected to cause a memory leak, since the subscriber never cancels the subscription to the publishers event, which leads to the fact that they both maintain a strong link to each other?
garbage-collection c # events
LEO
source share