Disposing a singleton instance (C#)
If a singleton implements IDisposable, what is the right way of disposing and re-creating an instance? One way would be to keep _disposed flag and check for it in the Instance property, but I'm not sure it is the right way to do this. A simple example: public sealed class Singleton: IDisposable { private static Singleton _instance; private object _lock; private UnmanagedResource _unmanaged; private bool _disposed; private Singleton() { _unmanaged = new UnmanagedResource(); _disposed = false; _lock = new object(); } public UnmanagedResource Unmanaged { get { return _unmanaged; } } public static