Archive

Archive for October, 2010

C# 5.0 async/await and GUI events

October 30, 2010 7 comments

A silly example. I’m tickled by the idea of treating a button as a simple task:

async void RefreshButtonAsync()
{
    for (;;)
    {
        await refreshButton.ClickAsync();
            // returns a Task that finishes 
            // next time the button is clicked
        await RefreshAsync();
    }
}

Wait for the button to be clicked, wait for the refresh to finish, repeat forever… that’s your task, little fella!
Read more…

Categories: Uncategorized Tags: , ,

C# 5.0 async/await

October 30, 2010 8 comments

First reaction: hurrah! This is the right language feature at the right time, and a perfect application of the power of compilers. I’ve been using JavaScript for the last few months and constantly wishing for a feature like this, but at the same time thinking how it could be done better in C#.

Second reaction: why would you want to have that await keyword in there?
Read more…

Categories: Uncategorized Tags: , ,