c#异步task示例分享(异步操作)
本文导语: c# Task异步操作 代码如下:using System;using System.Threading;using System.Threading.Tasks; namespace ConsoleApplication18{ class Program { static void Main(string[] args) { Func _processTimeFunc = new Func((string arg) => ...
c# Task异步操作
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication18
{
class Program
{
static void Main(string[] args)
{
Func _processTimeFunc = new Func((string arg) =>
{
return string.Format("{0} {1}", arg, DateTime.Now);
});
Task.Factory.FromAsync(_processTimeFunc.BeginInvoke, _processTimeFunc.EndInvoke, "Zhuzhou", null)
.ContinueWith((result) =>
{
Console.WriteLine(result.Result);
});
Console.ReadLine();
}
}
}