.NET 4 equivalent of Task.WhenAll()

后端 未结 3 837
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 08:09

In .NET 4, is there any functional equivalent to .NET 4.5\'s System.Threading.Tasks.Task.WhenAll()?

The goal is to wrap up multiple async tasks into a single one that is

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 08:39

    I think the closest thing built-in in .Net 4.0 is ContinueWhenAll(). You can make the continuationAction a simple tasks => tasks and use the returned Task.

    For performance reasons, you might want to use it with TaskContinuationOptions.ExecuteSynchronously.

提交回复
热议问题