如何在.net4.0中使用.net4.5的async/await

推薦文章:html

http://www.cnblogs.com/hj4444/p/3857771.htmlweb

http://www.cnblogs.com/dozer/archive/2012/03/06/async-and-await-in-web-application.html編程

 

通常喜歡學習新技術的同窗都用過.net4.5吧,那確定會被簡單、高效的異步編程模型所吸引吧。app

去年微軟發佈了Microsoft.Bcl.Async,該包由三個庫組成:Microsoft.Bcl、Microsoft.Bcl.Async和Microsoft.Bcl.Build。異步

 

async

 

或者直接在PM命令中輸入:

PM> Install-Package Microsoft.Bcl.Async異步編程

 

相關文章能夠參考:學習

Microsoft.Bcl.Async is Now Stable
async 與 await 在 Web 下的應用ui

 

可能會碰到的問題:spa

一、出現編譯異常

那須要你檢查一下各項目中是否都有引用。因爲使用了程序集統一的方式,解決方案中的全部工程都必須引用這三個庫。

二、使用異常

若是異常信息是「Message : Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)」,

那須要你去微軟官網下載.net4.0的KB2468871補丁來安裝。

 

KB2468871補丁-支持的操做系統

Windows 7 Service Pack 1, Windows Server 2003 Service Pack 2, Windows Server 2008, Windows Server 2008 R2 SP1, Windows Vista Service Pack 1, Windows XP Service Pack 3

相關文章
相關標籤/搜索