views:

131

answers:

1

If I have a class declared in assembly A, and am listening to it in assembly B, will this prevent garbage collection. Its a common situation, such as the one where you are listening to a property of an object in the business model from the ui.

i saw this question which talks about event listeners and garbage collection, but this question does not reference more than one assembly. I would hope the answer is the same (i.e. event listeners do not stop an object getting garbage collected) but there is that cross assembly boundary consideration.

+4  A: 

It is the same regardless of which assembly the classes originate from.

Rex M
any chance of a link to some documentation?
Aran Mulholland
@Aran Not specifically, no. Why do you *think* it might work differently?
Rex M
i cant quite remember, it was a while ago that i read that the garbage collector will collect cleanly unless the item being collected is referenced from another assembly, then even if the item is unreferenced from that assembly it will stop the item from being collected. the other reason i ask is that i keep seeing code for the weak event pattern.
Aran Mulholland