how to have a list(?) of instances without preventing garbage collection

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

Dear all,

I create a big number of a class instances of some class. Sometimes this
instances must be collected (all pointers are deleted, but instance is not
explicitly disposed).But sometimes I need to notify all living instances to
reread an init file.

Since I don't want to prevent a garbadge collection of the instances I don't
have an explicit collection of all living instances. So I am trying to use
shared event for notification.

But it seems that event delegate still preventing instances from GC.

Is it possible to somehow notify all living instances of class without
preventing a garbage collection?

Thanks a lot,

Boni
 
You need to search these newsgroups and the web for "weak reference
event handler". There are quite a few sites out there that tell you how
to build them. (Some designs are better than others.)

I had to do this in my system for similar reasons: objects subscribing
to static events that were then held forever because the event chain
held references to them.
 
Yep,
it is exactely what I need.
But I could not find a way to make a weak shared(static) handlers in .NET
1.1. Is it possible?
Could you point some info? (may be code sniplets or ideas?)

Thanks a lot in advance, Boni
 
Back
Top