• VS2010 + C#4.0使用 async + await


    方法一: 安装官方出的Microsoft.Bcl.Async包

    最新发布日期为 2014/4/12,版本1.0.168

    (不支持VS2010)

    1、解决方案-右键-管理解决方案的NuGet程序包

    2、搜索Microsoft.Bcl.Async,点击安装

     3、等待下载完成

     

     4、点击我接受

     

     5、发现引用下多出7个引用

    方法二、

    2011年微软出了async的预览版,当时使用async的方式如下

    1、准备好Visual Studio 2010 + SP1,无论什么版本。

    VS2010 SP1升级补丁:
    
    Microsoft Visual Studio 2010 Service Pack 1 官方离线下载版(ISO)1.48G地址:
    http://download.microsoft.com/download/E/B/A/EBA0A152-F426-47E6-9E3F-EFB686E3CA20/VS2010SP1dvd1.iso
     
    2、把Visual Studio Async CTP下载下来,并安装。
    3、建个项目,现在你已经可以使用asyncawait关键字了,而诸如WebClient下的DownloadStringTaskAsync方法,则是在%MyDocument%Microsoft Visual Studio Async CTPSamplesAsyncCtpLibrary.dll下定义的扩展方法。
     
     
     
     
     
     
    安装VS2010 SP1 升级程序
     
    如果双击安装程序,出现的界面不是下面,而是标题出现XXX维护

    则需要在注册表下,hkey_current_usersoftwaremicrosoftinstallerproducts

    在Products下找到一个ProductName叫 Microsoft Visual Studio 2010 Service Pack 1的项,并删除掉项9AC087DE786021C34B9333962F4249F1

    再次打开安装程序就正常了

    安装完SP1后,打开弹框报错:未能正确加载 “Microsoft.Data.Entity.Design.BootstrapPackage.BootstrapPackage,”

    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    
    reg query HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query delete HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigPackages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    
    reg delete HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f 
    reg delete HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f
    reg delete HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /va /f 
    
    reg delete HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f 
    reg delete HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f
    reg delete HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /va /f 
    
    reg delete HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f 
    reg delete HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /f
    reg delete HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigPackages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /va /f 
    
    
    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0AutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0Packages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    
    reg query HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{adfc4e66-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query delete HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigAutoLoadPackages{93694fa0-0397-11d1-9f4e-00a0c911004f} /v {7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} 
    reg query HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio10.0_ConfigPackages{7A4E8D96-5D5B-4415-9FAB-D6DCC56F47FB} /s
    View Code

    将上述代码复制到cmd下即可~如果一般不行来两遍。

  • 相关阅读:
    Hibernate逆向工程
    使用Hibernate连接Oracle 无法识别生成的SQL问题
    法线的变换矩阵
    搭建Struts2开发环境
    留存: struts2+jquery+json集成
    一些WebGL的资源
    9个WebGL的演示
    WPF动画制作简单的按钮动画
    C# /windowForm/WPF/SilverLight里面操作Word帮助类提供给大家
    高斯投影正反算的代码
  • 原文地址:https://www.cnblogs.com/code1992/p/11039657.html
Copyright © 2020-2023  润新知