.net 4.0中不提供async/await关键字 [英] async/await keywords not available in .net 4.0

查看:123
本文介绍了.net 4.0中不提供async/await关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#4.0中使用async/await,并且已经安装了以下软件包:

I would like to use the async/await in C# 4.0 and I have installed the following package:

http://www.nuget.org/packages/Microsoft.Bcl.Async/

问题是我没有可用的异步/等待关键字.

The problem is that I do not have async/await keywords available.

我正在将VS2010与SP1配合使用.

I am using VS2010 with SP1.

谢谢.

推荐答案

您不会得到比 Jon Skeet的更好的答案.

唯一受支持的方法是将 VS2012 Microsoft.Bcl.Async一起使用.

The only supported way to do this is to use VS2012 with Microsoft.Bcl.Async.

VS2010很难与async/await一起使用.有一个旧的Async CTP程序包(其中有许多从未修复的错误),充当VS2010的附加"/部分替换".但是,该软件包无法与VS2010更新一起很好地工作.因此,您必须首先找到一个旧的CTP安装程序的版本,尝试安装 some VS更新,然后查看CTP是否有效.如果您已经安装了所有VS2010更新,则没有CTP版本可以使用.我认为,一旦发现可以安装有效CTP的更新情况,然后就可以安装其他更新.

VS2010 is very difficult to get working with async/await. There was an old Async CTP package (which had many bugs that were never fixed) that acted as an "add-on"/"partial replacement" to VS2010. However, that package never worked well with the VS2010 updates. So, you'd have to first find a version of one of the old CTP installers, play around with installing some VS updates, and then see if the CTP works. If you've already installed all your VS2010 updates then no version of the CTP will work. I think once you find an update situation where you can install a working CTP, then you can install the other updates.

完成所有这些工作之后,您仍然会遇到async的错误缠身(且肯定未优化)的实现.

After all this work, you'll still end up with a bug-ridden (and definitely unoptimized) implementation of async.

或者,您可以按照Jon Skeet的建议进行操作,并使用Microsoft.Bcl.Async下载免费版本的VS2012 Express,并获得完全受支持的解决方案.

Or, you can do as Jon Skeet suggested and download the free version of VS2012 Express with Microsoft.Bcl.Async and have a fully supported solution.

这篇关于.net 4.0中不提供async/await关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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