.NET 4当量Task.WhenAll的() [英] .NET 4 equivalent of Task.WhenAll()

查看:141
本文介绍了.NET 4当量Task.WhenAll的()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET 4中,没有任何功能上等同于.NET 4.5的<一个href="http://msdn.microsoft.com/en-us/library/hh160384%28v=vs.110%29.aspx">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中是的 ContinueWhenAll() 。您可以在 continuationAction 一个简单的任务=&GT;任务并使用返回工作

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的()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆