Sometime back I wrote a post about What's new in C# 5.0 and in there I wrote about async modifier and await operator. Though async and await was introduced with .NET 4.5, haven’t you ever wished to use them projects targeted .NET Framework 4.0, Silverlight 4 or Windows Phone 7.5. Well there were many times I wanted use async and await, but since I was on .NET 4.0, I had to stick to legacy asynchronous programming patterns.
But now we will not have to go to other choices anymore. If your project is targeted are on .NET Framework 4.0, Silverlight 4, Windows Phone 7.5 or higher versions of any of these and if you want you async/await, you can go for it using this Async Targeting Pack Nuget Package which was released by .NET Base Class Library Team.
To add a reference to this NuGet Package, right click on your project, select “Manage Nuget Packages” and search for Microsoft.Bcl.Async.
Please make sure to select "Include Prerelease" on top left drop down and since this package is marked as prerelease software, there are some known issues and issues are expected.
You can also install this package via the Package Manager Console by running the following command:
install-package Microsoft.Bcl.Async –pre
Important thing to note is, you need to open your project using Visual Studio 2012 and set the target framework. Because this package is not supported in Visual Studio 2010 and if you open the project using Visual Studio 2010 and install the package, you will still be not able to use async/await.
Happy Coding.
Regards,
Jaliya
Nice post very helpful
ReplyDeleteDBAKings
Excellent Post. Also visit http://www.msnetframework.com/framework.php
ReplyDelete