using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AsyncAwatiConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Example();
            string result = Console.ReadLine();
            Console.WriteLine("You typed: " + result);
        }
        public static async void Example()
        {
            int t = await Task.Run(() => Allocate());
        }

        public static  void Example2()
        {
            Task<int> task = new Task<int>(() =>
            {
                return 11;
            });
            task.Start();
            task.Wait();
        }
        static int Allocate()
        {
            // Compute total count of digits in strings.
            int size = 0;
            for (int z = 0; z < 100; z++)
            {
                for (int i = 0; i < 1000000; i++)
                {
                    string value = i.ToString();
                    if (value == null)
                    {
                        return 0;
                    }
                    size += value.Length;
                }
            }
            return size;
        }
    }
}

  

相关文章:

  • 2021-10-24
  • 2021-12-27
  • 2022-12-23
  • 2021-09-18
  • 2021-11-25
  • 2022-12-23
  • 2021-10-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案