c#异步task示例分享(异步操作)

前端技术 2023/09/04 C#

c# Task异步操作

复制代码 代码如下:

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();
        }

    }
}

本文地址:https://www.stayed.cn/item/11390

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。