private void button2_Click(object sender, EventArgs e)
{
Task.Run(async () => await Inta());
}
public async Task Inta()
{
bool aa = false; bool bb = false; bool cc = false;
var taskResults = await Task.WhenAll(
Task.Run(() => aa ? true : a()),//三元运算符判断要不要执行方法
Task.Run(() => bb ? true : b()),
Task.Run(() => cc ? true : c()));
//Console.WriteLine(taskResults.Count().ToString());
}
public bool a()
{
Console.WriteLine("a");
return true;
}
public bool b()
{
Console.WriteLine("b");
return true;
}
public bool c()
{
Console.WriteLine("c");
return true;
}