One of the questions I get asked many times is how to create a Singleton using .Net and C#. Several problems occur when trying to implement a robust Singleton. For instance, locking issues when using static (shared) members to keep track of the instance. In Lazy init singleton David Notario explains how to make a Singleton and KNOW when the Singleton is being instantiated. Because of the ‘undefined’ (or should I say ‘whenever but in time’) attitude of the .NET Runtime singletons might slowdown the initialization of an application because the runtime is busy creating all Singletons.
-
Building Singletons