使用异步/等待执行并行任务 [英] Execute parallel tasks with async/await

查看:64
本文介绍了使用异步/等待执行并行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Silverlight中执行多个异步任务.

I need to execute multiple async tasks in Silverlight.

我可以使用的第三方包装说明的文件

Documentation of the 3rd party package states I can use

await Task.WhenAll()

很遗憾,silverlight仅具有Task.WaitAll(),因此无法等待.如果我尝试使用它,则会陷入僵局(我想-因为整个事情都死了)

Unfortunately silverlight only have Task.WaitAll() and it is not awaitable. If I try to use it I get deadlock (I assume - because whole thing freezes)

在异步方法中使用什么合适的模式?

What is the proper pattern to use in async method?

推荐答案

对于Silverlight,我假设您正在使用 Microsoft .Bcl.Async 包.

For Silverlight I assume you're using the Microsoft.Bcl.Async package.

由于此(附加)程序包无法修改(内置)Task类型,因此您会在TaskEx类型中找到一些有用的方法.包括WhenAll:

Since this (add-on) package cannot modify the (built-in) Task type, you'll find some useful methods in the TaskEx type. Including WhenAll:

await TaskEx.WhenAll(...);

这篇关于使用异步/等待执行并行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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