Async CTP (SP1 Refresh)

Visual Studio Blog

By Robin Reynolds-Haertle

This morning, we released an updated version of the Visual Studio Async CTP (SP1 Refresh) that’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 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 await and async 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.

// C#
async Task<int> SumPageSizesAsync(IList<Uri> uris)
{
    int total = 0;
    var statusText = new TextBox();

    foreach (var uri in uris)
    {
        statusText.Text = string.Format("Found {0} bytes ...", total);
        var data = await new WebClient().DownloadDataTaskAsync(uri);
        total += data.Length;
    }

    statusText.Text = string.Format("Found {0} bytes total", total);
    return total;
}
' Visual Basic
Async Function SumPageSizesAsync(uris As IList(Of Uri)) As Task(Of Integer)
    Dim total As Integer = 0
    Dim statusText = New TextBox()

    For Each uri In uris
        statusText.Text = String.Format("Found {0} bytes ...", total)
        Dim Data = Await New WebClient().DownloadDataTaskAsync(uri)
        total += Data.Length
    Next

    statusText.Text = String.Format("Found {0} bytes total", total)
    Return total
End Function

Note: The CTP is released with an “as is” 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.

Download and Installation

Follow these three steps, in order, to prepare your computer for the CTP:

1. If you have the previous Async CTP on your computer, uninstall it first. To do this, go to Control Panel > Uninstall a program > View installed updates, search for the two updates with “Async” in their names, and uninstall both of them.

2. If you want to do Windows Phone 7 development, install the Windows Phone Developer Tools. If you are using Visual Basic, also install Visual Basic for Windows Phone Developer Tools.

3. Install Microsoft Visual Studio 2010 Service Pack 1. 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’ll need to reinstall the service pack.

Once you have completed the steps above, download and install the Visual Studio Async CTP (SP1 Refresh).

Please let us know what you think! Thanks!

0 comments

Discussion is closed.

Feedback usabilla icon