在.NET 4中使用异步计谋 [英] Using async-await on .net 4

查看:143
本文介绍了在.NET 4中使用异步计谋的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我开始创建,将获利很多从C#5的异步等待功能的应用程序。但我不知道要使用的异步运行的VS和版本。

I'm currently starting to create an application that would profit a lot from C# 5's async-await feature. But I'm not sure which version of VS and of the async runtime to use.

看着OS人气排行榜,我需要支持Windows XP又三年左右。它看起来像.NET 4.5只运行在新版本的Windows,所以我需要面向.NET 4.0。在开发机器使用Windows 7,因此使用VS的较新版本是没有问题的。

Looking at OS popularity charts, I'll need to support Windows XP for another three years or so. It looks like .net 4.5 runs only on newer versions of Windows, so I need to target .net 4.0. The development machines use Windows 7, so using a newer version of VS is not a problem.

现在我需要先选择一个编译器用于执行此操作:

  • 在VS2010与AsyncCTP
  • 在VS2012 preVIEW(一旦它到达最后一个),设定目标为.NET 4.0
  • 在单声道(貌似2.12已异步计谋,我preFER /我用VS了MonoDevelop中为IDE)

哪一个具有较少code根的错误?看<一href="http://msmvps.com/blogs/jon_skeet/archive/2012/01/12/eduasync-part-18-changes-between-the-async-ctp-and-the-visual-studio-11-$p$pview.aspx">Jon飞碟双向的博客的VS2012 preVIEW采用了永不code-发电机比CTP。

Which one has fewer code-gen bugs? Looking at Jon Skeet's blog the VS2012 Preview uses a never code-generator than the CTP.

更重要的是要使用的运行时间?

请问VS2012包含一个可再发行异步运行时使用与.NET 4?

Does VS2012 contain a redistributable async runtime for use with .net 4?

我设法编译code,以preVIEW,通过引用AsyncCTP运行。但是,由于CTP有奇怪的发牌条件,这看起来并不像一个良好的长期解决方案。

I managed to compile code, with the preview, by referencing the AsyncCTP runtime. But since the CTP has strange licensing conditions, that doesn't look like a good long term solution.

或者我应该使用一个第三方的实施?也许单有一个?

Or should I use a third party implementation? Perhaps mono has one?

有关分发库我preFER干脆把,而不是某种安装程序的DLL在同一个目录下的应用程序。

For distributing the library I prefer simply putting the dll in the same directory as the application, instead of some kind of installer.

我也会喜欢它,如果我的二进制文件将工作没有在单声道的Linux / MacOS的变化。因此,运行时要么是与任何单(2.12可能)还内置兼容,或允许在非Windows上使用的操作系统。

I'd also like it if my binaries would work without changes on mono+Linux/MacOS. So the runtime should either be compatible with whatever mono (2.12 probably) has built in, or allow use on non windows OSs.

推荐答案

微软发布了异步定位包( Microsoft.Bcl.Async)通过的NuGet 作为替代AsyncCTP。

Microsoft released the Async Targeting Pack (Microsoft.Bcl.Async) through Nuget as a replacement for the AsyncCTP.

您可以阅读更多关于它在这里:<一href="http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx">http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx.

You can read more about it here: http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx.

您可以了解这里的previous版本:<一href="http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx">http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx.

You can read about the previous version here: http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx.

由于这组官方支持,我现在相信了针对XP +异步的最好的办法是使用Visual Studio 2012 + C#5 +异步定位包。

As this pack is officially supported, I now believe the best option for targeting XP + async would be using Visual Studio 2012 + C#5 + Async Targeting Pack.

如果你觉得有必要针对.NET 3.5尽管如此,你仍然可以使用(我) AsyncBridge对.NET 3.5

If you feel the need to target .NET 3.5 though, you can still use (my) AsyncBridge for .NET 3.5.

这篇关于在.NET 4中使用异步计谋的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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