/// <summary> /// Create a singleton instance of the <see cref="SingletonClass" />. /// </summary> /// <returns>The singleton instance of the class.</returns> public static SingletonClass CreateInstance() { if (singleInstance == null) { lock (mylock) { if (singleInstance == null) { singleInstance = new SingletonClass(); } } } return(singleInstance); }
/// <summary> /// Get a singleton instance of the <see cref="SingletonClass" />. /// </summary> public void SomeMethod() { this.a = SingletonClass.CreateInstance(); this.a.Foo(); }