How can I cancel Task.WhenAll?

前端 未结 4 964
执笔经年
执笔经年 2020-12-10 11:20

Currenly using the following code to wait for a collection of tasks to complete. However, I now have a situation where I want to be able to cancel/abort the WhenAll call, v

4条回答
  •  北海茫月
    2020-12-10 11:36

    More elegant from my opinion :

    await Task.Run(()=> Task.WaitAll(myArrayOfTasks), theCancellationToken);
    

提交回复
热议问题