{"id":1593,"date":"2011-04-13T07:21:00","date_gmt":"2011-04-13T07:21:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2011\/04\/13\/async-ctp-sp1-refresh\/"},"modified":"2019-02-14T15:39:00","modified_gmt":"2019-02-14T23:39:00","slug":"async-ctp-sp1-refresh","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/async-ctp-sp1-refresh\/","title":{"rendered":"Async CTP (SP1 Refresh)"},"content":{"rendered":"<p>By Robin Reynolds-Haertle<\/p>\n<p>This morning, we released an updated version of the <a href=\"http:\/\/msdn.microsoft.com\/en-US\/vstudio\/async\">Visual Studio Async CTP (SP1 Refresh)<\/a> that&rsquo;s compatible with Visual Studio 2010 SP1 and Windows Phone 7!<\/p>\n<h3>What Is the Visual Studio Async CTP (SP1 Refresh)?<\/h3>\n<p>The Async CTP previews a language feature that is in the next version of Visual Basic and C#. By using this feature, you can call into asynchronous APIs without having to split your code across multiple methods or lambda expressions. No more callbacks! This is all thanks to the new <strong>await<\/strong> and <strong>async<\/strong> keywords that enable you to write asynchronous methods that can pause execution without consuming a thread, and then resume later, right where they left off.<\/p>\n<pre class=\"code\"><span style=\"background: white;color: green\">\/\/ C#\n<\/span><span style=\"background: white;color: blue\"><span style=\"background-color: #ffff00\">async<\/span> <\/span><span style=\"background: white;color: #2b91af\">Task<\/span><span style=\"background: white;color: black\">&lt;<\/span><span style=\"background: white;color: blue\">int<\/span><span style=\"background: white;color: black\">&gt; SumPageSizesAsync(<\/span><span style=\"background: white;color: #2b91af\">IList<\/span><span style=\"background: white;color: black\">&lt;<\/span><span style=\"background: white;color: #2b91af\">Uri<\/span><span style=\"background: white;color: black\">&gt; uris)\n{\n    <\/span><span style=\"background: white;color: blue\">int <\/span><span style=\"background: white;color: black\">total = 0;\n    <\/span><span style=\"background: white;color: blue\">var <\/span><span style=\"background: white;color: black\">statusText = <\/span><span style=\"background: white;color: blue\">new <\/span><span style=\"background: white;color: #2b91af\">TextBox<\/span><span style=\"background: white;color: black\">();\n\n    <\/span><span style=\"background: white;color: blue\">foreach <\/span><span style=\"background: white;color: black\">(<\/span><span style=\"background: white;color: blue\">var <\/span><span style=\"background: white;color: black\">uri <\/span><span style=\"background: white;color: blue\">in <\/span><span style=\"background: white;color: black\">uris)\n    {\n        statusText.Text = <\/span><span style=\"background: white;color: blue\">string<\/span><span style=\"background: white;color: black\">.Format(<\/span><span style=\"background: white;color: #a31515\">\"Found {0} bytes ...\"<\/span><span style=\"background: white;color: black\">, total);\n        <\/span><span style=\"background: white;color: blue\">var <\/span><span style=\"background: white;color: black\">data = <\/span><span style=\"background: white;color: blue\"><span style=\"background-color: #ffff00\">await<\/span> new <\/span><span style=\"background: white;color: #2b91af\">WebClient<\/span><span style=\"background: white;color: black\">().DownloadDataTaskAsync(uri);\n        total += data.Length;\n    }\n\n    statusText.Text = <\/span><span style=\"background: white;color: blue\">string<\/span><span style=\"background: white;color: black\">.Format(<\/span><span style=\"background: white;color: #a31515\">\"Found {0} bytes total\"<\/span><span style=\"background: white;color: black\">, total);\n    <\/span><span style=\"background: white;color: blue\">return <\/span><span style=\"background: white;color: black\">total;\n}<\/span><\/pre>\n<pre class=\"code\"><span style=\"background: white;color: green\">' Visual Basic\n<\/span><span style=\"background: white;color: blue\"><span style=\"background-color: #ffff00\">Async<\/span> Function <\/span><span style=\"background: white;color: black\">SumPageSizesAsync(uris <\/span><span style=\"background: white;color: blue\">As <\/span><span style=\"background: white;color: #2b91af\">IList<\/span><span style=\"background: white;color: black\">(<\/span><span style=\"background: white;color: blue\">Of <\/span><span style=\"background: white;color: #2b91af\">Uri<\/span><span style=\"background: white;color: black\">)) <\/span><span style=\"background: white;color: blue\">As <\/span><span style=\"background: white;color: #2b91af\">Task<\/span><span style=\"background: white;color: black\">(<\/span><span style=\"background: white;color: blue\">Of Integer<\/span><span style=\"background: white;color: black\">)\n    <\/span><span style=\"background: white;color: blue\">Dim <\/span><span style=\"background: white;color: black\">total <\/span><span style=\"background: white;color: blue\">As Integer <\/span><span style=\"background: white;color: black\">= 0\n    <\/span><span style=\"background: white;color: blue\">Dim <\/span><span style=\"background: white;color: black\">statusText = <\/span><span style=\"background: white;color: blue\">New <\/span><span style=\"background: white;color: #2b91af\">TextBox<\/span><span style=\"background: white;color: black\">()\n\n    <\/span><span style=\"background: white;color: blue\">For Each <\/span><span style=\"background: white;color: black\">uri <\/span><span style=\"background: white;color: blue\">In <\/span><span style=\"background: white;color: black\">uris\n        statusText.Text = <\/span><span style=\"background: white;color: blue\">String<\/span><span style=\"background: white;color: black\">.Format(<\/span><span style=\"background: white;color: #a31515\">\"Found {0} bytes ...\"<\/span><span style=\"background: white;color: black\">, total)\n        <\/span><span style=\"background: white;color: blue\">Dim <\/span><span style=\"background: white;color: black\">Data = <\/span><span style=\"background: white;color: blue\"><span style=\"background-color: #ffff00\">Await<\/span> New <\/span><span style=\"background: white;color: #2b91af\">WebClient<\/span><span style=\"background: white;color: black\">().DownloadDataTaskAsync(uri)\n        total += Data.Length\n    <\/span><span style=\"background: white;color: blue\">Next\n\n    <\/span><span style=\"background: white;color: black\">statusText.Text = <\/span><span style=\"background: white;color: blue\">String<\/span><span style=\"background: white;color: black\">.Format(<\/span><span style=\"background: white;color: #a31515\">\"Found {0} bytes total\"<\/span><span style=\"background: white;color: black\">, total)\n    <\/span><span style=\"background: white;color: blue\">Return <\/span><span style=\"background: white;color: black\">total\n<\/span><span style=\"background: white;color: blue\">End Function<\/span><span style=\"background: white;color: blue\">\n<\/span><\/pre>\n<p><b><\/b><\/p>\n<p><b>Note<\/b>: The CTP is released with an &ldquo;as is&rdquo; license. This does not constitute encouragement for you to use the CTP for your production code. The CTP is a technology preview that is unsupported, and you use it at your own risk. Because we received many requests from developers asking to use the CTP for production code, we changed the license to allow using the CTP in applications you submit to the Marketplace. As always, we recommend that you test your code thoroughly.<\/p>\n<h3>Download and Installation<\/h3>\n<p>Follow these three steps, in order, to prepare your computer for the CTP:<\/p>\n<p>1. If you have the previous Async CTP on your computer, uninstall it first. To do this, go to Control Panel &gt; Uninstall a program &gt; View installed updates, search for the two updates with &ldquo;Async&rdquo; in their names, and uninstall both of them.<\/p>\n<p>2. If you want to do Windows Phone 7 development, install the <a href=\"http:\/\/www.microsoft.com\/downloads\/en\/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce\">Windows Phone Developer Tools<\/a>. If you are using Visual Basic, also install <a href=\"http:\/\/www.microsoft.com\/downloads\/en\/details.aspx?FamilyID=4e97ea70-e479-4c05-814f-639d71690e5d&amp;displaylang=en\">Visual Basic for Windows Phone Developer Tools<\/a>.<\/p>\n<p>3. Install <a href=\"http:\/\/www.microsoft.com\/downloads\/en\/details.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5\">Microsoft Visual Studio 2010 Service Pack 1<\/a>.<b> <\/b>You must install the service pack after you install the Windows Phone Developer Tools. If you installed Windows Phone Developer Tools after installing the service pack, you&rsquo;ll need to reinstall the service pack.<\/p>\n<p>Once you have completed the steps above, <a href=\"http:\/\/msdn.microsoft.com\/en-US\/vstudio\/async\">download<\/a> and install the Visual Studio Async CTP (SP1 Refresh).<\/p>\n<p>Please <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/async\/threads\">let us know what you think<\/a>! Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Robin Reynolds-Haertle This morning, we released an updated version of the Visual Studio Async CTP (SP1 Refresh) that&rsquo;s compatible with Visual Studio 2010 SP1 and Windows Phone 7! What Is the Visual Studio Async CTP (SP1 Refresh)? The Async CTP previews a language feature that is in the next version of Visual Basic and [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[1383,653,13],"class_list":["post-1593","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-c","tag-visual-basic","tag-visual-studio-2010"],"acf":[],"blog_post_summary":"<p>By Robin Reynolds-Haertle This morning, we released an updated version of the Visual Studio Async CTP (SP1 Refresh) that&rsquo;s compatible with Visual Studio 2010 SP1 and Windows Phone 7! What Is the Visual Studio Async CTP (SP1 Refresh)? The Async CTP previews a language feature that is in the next version of Visual Basic and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/1593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=1593"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/1593\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=1593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=1593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=1593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}