Weak References and Disposable objects.

Posted by Steve Sheldon on Stack Overflow See other posts from Stack Overflow or by Steve Sheldon
Published on 2010-05-15T18:16:44Z Indexed on 2010/05/15 18:24 UTC
Read the original article Hit count: 398

Filed under:
|

In C# it is possible to create weak references to objects as described here:

WeakReference Class

In .net some classes also implement the IDisposable interface. Calling the Dispose method of this interface is performed to manually dispose of any managed or unmanaged resources currently being held onto. An example might be a Bitmap object or class.

If I assign an object that implements IDisposable to a weak reference, will Dispose be called if the weak reference collects the object?

© Stack Overflow or respective owner

Related posts about c#

Related posts about garbage-collection