Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get a singleton instance of the <see cref="SingletonClass" />.
 /// </summary>
 public void SomeMethod()
 {
     this.a = SingletonClass.CreateInstance();
     this.a.Foo();
 }