鉴于此列表:
var tasks = new List<Task>
{
MyMethod1,
MyMethod2,
MyMethod3
};
Run Code Online (Sandbox Code Playgroud)
还有这些方法:
async Task MyMethod1()
{
await SomeOtherMethod1();
}
async Task MyMethod2()
{
await SomeOtherMethod2();
}
async Task MyMethod3()
{
await SomeOtherMethod3();
}
Run Code Online (Sandbox Code Playgroud)
是否可以在每个按顺序完成的情况下执行此操作task(无并发):
async Task MyMethod1()
{
await SomeOtherMethod1();
}
async Task MyMethod2()
{
await SomeOtherMethod2();
}
async Task MyMethod3()
{
await SomeOtherMethod3();
}
Run Code Online (Sandbox Code Playgroud)
我还没有找到任何完成此操作的方法或示例。foreach只是把它们全部解雇。有await foreach,但Task不包含 的公共实例或扩展定义GetAsyncEnumerator。
| 归档时间: |
|
| 查看次数: |
276 次 |
| 最近记录: |