async/await 关键字在 .net 4.0 中不可用 [英] async/await keywords not available in .net 4.0

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

问题描述

我想在 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/

问题是我没有可用的 async/await 关键字.

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

我使用的是 VS2010 和 SP1.

I am using VS2010 with SP1.

谢谢.

推荐答案

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

唯一支持的方法是将 VS2012Microsoft.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 安装程序之一的版本,安装一些 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.

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

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