Hi –

I have a *ComponentCatalog* class that manages a list of
*System.ComponentModel.Component*. It's actually a façade for a
Dictionary<string,Component>.

I want this class to be able to return each component when they are
requested, but I don't want the class to keep references to Components
when no one else is using them.

I am subscribing to the Disposed event of each component and removing
the reference from the Dictionary<string,Component> when the Component
gets disposed. However I cannot assure that the developer will call
Component.Dispose(), hence the Disposed event would never be raised
and the Component won't never be taken out from the Dictionary.

I wonder if I should use WeakReferences to do this, and what would be
the drawback of doing so.

I appreciate any comments.
Thanks
Matias

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to