110,533
社区成员
发帖
与我相关
我的任务
分享
Dictionary<string, Action<object>> dictAction = new Dictionary<string, Action<object>>();
dictAction["m1"] = method1;
dictAction["m2"] = method2;
foreach (var a in dictAction)
{
Task.Factory.StartNew(a.Value, a.Key);
}
void method1(object state)
{
}
void method2(object state)
{
}
public static void Main(string[] args)
{
int[] arr = { 1, 2, 3 };
foreach (var item in arr)
{
Task.Factory.StartNew(x => { Console.WriteLine(x); }, item);
}
Console.ReadLine();
}