{"id":3521,"date":"2012-04-08T17:09:00","date_gmt":"2012-04-08T17:09:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/asyncbridge-async-on-net-4-0-using-vs11\/"},"modified":"2016-07-28T10:50:45","modified_gmt":"2016-07-28T10:50:45","slug":"asyncbridge-async-on-net-4-0-using-vs11","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/asyncbridge-async-on-net-4-0-using-vs11\/","title":{"rendered":"AsyncBridge? Async on .NET 4.0 using VS11"},"content":{"rendered":"<p>I&#8217;ve just found something quite cool. It&#8217;s a <a href=\"https:\/\/gist.github.com\/1961087\">code snippet<\/a> that lets you use the real VS 11 C#5 compiler to write code that uses the async and await keywords, but to target .NET 4.0. It was published by Daniel Grunwald (from SharpDevelop).<\/p>\n<p>That means I can stop using the Async CTP for VS2010, which is not at all supported anymore, and <a href=\"http:\/\/blogs.msdn.com\/b\/lucian\/archive\/2012\/03\/25\/asyncctp-installation-problems-and-vs11.aspx\">a pain to install if you have windows updates turned on<\/a>. Obviously I couldn&#8217;t ask all my users to install .NET 4.5 beta, but .NET Demon is a VS 2010 extension, so we already have .NET 4.0. At the time of writing, VS11 is in beta still, but hopefully it&#8217;s stable enough for my team to use!<\/p>\n<p>I would have written the code myself, but I had the wrong impression that the C# 5 beta compiler only looked in mscorlib for the helper classes it needs to implement async methods. Turns out you can provide them yourself.<\/p>\n<p>  You can get the code here:<br \/><a href=\"https:\/\/gist.github.com\/1961087\">https:\/\/gist.github.com\/1961087<\/a><\/p>\n<p>You just add it to your project, and the compiler will apparently pick it up and use it to implement async\/await. I&#8217;m at my parents&#8217; place for Easter without access to a machine with VS 11 to try it out. Let me know whether you get it to work!<\/p>\n<p>This reminds me of <a href=\"http:\/\/code.google.com\/p\/linqbridge\/\">LINQBridge<\/a>, which let us use C# 3 LINQ, but only require .NET 2. We should stick up a webpage to explain, with a nice easy dll, put it in nuget, and call it AsyncBridge.<\/p>\n<p>If you were really enthusiastic, you could re-implement the skeleton of the Task Parallel Library against .NET 2 to use async\/await without even requiring .NET 4. Our usage stats suggest that practically everyone that uses Red Gate tools already has .NET 4 installed though, so I don&#8217;t think I&#8217;ll go to the effort.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve just found something quite cool. It&#8217;s a code snippet that lets you use the real VS 11 C#5 compiler to write code that uses the async and await keywords, but to target .NET 4.0. It was published by Daniel Grunwald (from SharpDevelop). That means I can stop using the Async CTP for VS2010, which&#8230;&hellip;<\/p>\n","protected":false},"author":5844,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3521","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/5844"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3521"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3521\/revisions"}],"predecessor-version":[{"id":42141,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3521\/revisions\/42141"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3521"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}