The c asynchronous task example shares the of asynchronous operation

  • 2020-06-15 10:08:31
  • OfStack

c# Task asynchronous operation


using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string, string> _processTimeFunc = new Func<string, string>((string arg) =>
           {
               return string.Format("{0} {1}", arg, DateTime.Now);
           });
            Task.Factory.FromAsync<string, string>(_processTimeFunc.BeginInvoke, _processTimeFunc.EndInvoke, "Zhuzhou", null)
                .ContinueWith((result) =>
                {
                    Console.WriteLine(result.Result);
                });
            Console.ReadLine();
        }
    }
}


Related articles: