Пример #1
0
        static void Main(string[] args)
        {
            var conObj  = MyConnection.Instance();
            var conObj2 = MyConnection.Instance();

            Console.WriteLine(conObj == conObj2);
        }
Пример #2
0
        static void Main(string[] args)
        {
            MyConnection conObj  = null;
            MyConnection conObj2 = null;

            Task[] tasks = new Task[2];

            tasks[0] = Task.Run(() =>
            {
                conObj = MyConnection.Instance();
            });

            tasks[1] = Task.Run(() =>
            {
                conObj2 = MyConnection.Instance();
            });

            Task.WaitAll(tasks);

            Console.WriteLine(conObj == conObj2);
        }