Ejemplo n.º 1
0
 public static DataServer GetInstance()
 {
     if (_container == null)
     {
         _container = new DataServer();
     }
     return(_container);
 }
Ejemplo n.º 2
0
        //private static void Case1()
        //{
        //      DataServer server1 = new DataServer();
        //    DataServer server2 = new DataServer();

        //    Console.WriteLine(server1.GetHashCode());
        //    Console.WriteLine(server2.GetHashCode());

        //    server1.DoSomthing();
        //    server2.DoSomthing();
        //}

        private static void Case2()
        {
            DataServer server1 = DataServer.GetInstance();
            DataServer server2 = DataServer.GetInstance();

            Console.WriteLine(server1.GetHashCode());
            Console.WriteLine(server2.GetHashCode());

            server1.DoSomthing();
            server2.DoSomthing();
        }