observing a reference variable's instance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pieter Breed

    #1

    observing a reference variable's instance

    Hi,

    I would like to have a reference to class instance, but not influence
    when it should or should not be garbage collected. Is this possible?

    I have a cache of objects that I use to send update signals with. The
    cache manager should allow these instances to go out of scope and be
    garbage collected, in other code. Normally the cache's reference to
    the instance will prevent that instance from being collected. Is there
    a way around this?

    Regards,
    Pieter

  • Mattias Sjögren

    #2
    Re: observing a reference variable's instance

    Pieter,
    >I would like to have a reference to class instance, but not influence
    >when it should or should not be garbage collected. Is this possible?
    Use the WeakReference class.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...