C#中,Task Action错误
代码这一部分,Task task1 = new Task(action,null);
提示报错原因是: 参数 1: 无法从“System.Action”转换为“System.Action”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApp中task的状态
{
class Program
{
private static void Method(int i)
{
i =i *1000;
Thread.Sleep(i);
}
static void Main(string[] args)
{
Action<int> action = new Action<int>(Method);
Task task1 = new Task(action,null);
task1.Start();
}
}
}