Disposable Registry: good pattern?
Posted
by illdev
on Stack Overflow
See other posts from Stack Overflow
or by illdev
Published on 2010-05-23T20:25:06Z
Indexed on
2010/05/23
20:31 UTC
Read the original article
Hit count: 289
c#
|idisposable
Imagine a:
public class Global : IDisposable
{
private static readonly List<IDisposable> Disposables = new List<IDisposable>();
public void ApplicationStart()
{
var heavyLifter = new HeavyLifter();
Disposables.Add(heavyLifter);
}
public void Dispose()
{
Disposables.ForEach(d => d.Dispose());
}
}
I am somewhat inexperienced with IDisposable. Is this a viable pattern?
© Stack Overflow or respective owner