Esempio n. 1
0
        public static void Main()
        {
            // 1
            //SingletonPattern.getSingletonObject();
            //SingletonPattern.getSingletonObject();
            //SingletonPattern.getSingletonObject();

            // 2
            //Task firstTask = new Task(() =>
            //{
            //    SingletonPattern.getSingletonObject();
            //});

            //Task secondTask = new Task(() =>
            //{
            //    SingletonPattern.getSingletonObject();

            //});

            //Task thirdTask = new Task(() =>
            //{
            //    SingletonPattern.getSingletonObject();
            //});

            //firstTask.Start();
            //secondTask.Start();
            //thirdTask.Start();

            // 3
            //SingletonPattern.callAsync();
            //SingletonPattern.callAsync();
            //SingletonPattern.callAsync();

            //4
            //SingletonPattern.callAsync();
            //SingletonPattern.callAsync();
            //SingletonPattern.callAsync();

            //5
            SingletonPattern.callAsync();
            SingletonPattern.callAsync();
            SingletonPattern.callAsync();

            Console.WriteLine();
        }
Esempio n. 2
0
 public async static void callAsync()
 {
     await Task.Run(() => SingletonPattern.getSingletonObject());
 }