问题描述
在.NET 4中,没有任何功能上等同于.NET 4.5的System.Threading.Tasks.Task.WhenAll()?
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 completed when all of its constituent tasks are done.
推荐答案
我认为最接近内置在.NET 4.0中是的。您可以在 continuationAction
一个简单的任务=>任务
并使用返回工作
。
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
.
有关性能方面的原因,你可能想使用它与 TaskContinuationOptions.ExecuteSynchronously
。
For performance reasons, you might want to use it with TaskContinuationOptions.ExecuteSynchronously
.
这篇关于.NET 4当量Task.WhenAll的()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!