Async articles

I am pleased to announce that MSDN Magazine is doing a special issue this month on the new “async-await” feature that we are working on for the next versions of C# and Visual Basic. If this subject interests you, see my introductory article for beginners, Mads Torgersen’s article on how it works behind the scenes…

8

Refreshing the Async CTP

Good morning everyone! I am pleased to tell you that the C# and VB teams are announcing a “refresh” of the async Community Technology Preview at MIX11 today, and that it is as of right now available on the Async CTP site. Recall that the CTP release is an early look at our thinking for the proposed async…

17

Asynchrony in C# 5, Part Eight: More Exceptions

(In this post I’ll be talking about exogenous, vexing, boneheaded and fatal exceptions. See this post for a definition of those terms.) If your process experiences an unhandled exception then clearly something bad and unanticipated has happened. If its a fatal exception then you’re already in no position to save the process; it is going…

34

Asynchrony in C# 5, Part Seven: Exceptions

Resuming where we left off (ha ha ha!) after that brief interruption: exception handling in “resumable” methods like our coroutine-like asynchronous methods is more than a little bit weird. To get a sense of how weird it is, you might want to first refresh your memory of my recent series on the design of iterator…

5

Asynchrony in C# 5 Part Six: Whither async?

A number of people have asked me what motivates the design decision to require any method that contains an “await” expression to be prefixed with the contextual keyword “async”. Like any design decision there are pros and cons here that have to be evaluated in the context of many different competing and incompossible principles. There’s…

37

Asynchrony in C# 5 Part Five: Too many tasks

Suppose a city has a whole bunch of bank branches, each of which has a whole bunch of tellers and one gofer. There are a whole bunch of customers in the city, each of whom wants to withdraw a whole bunch of money from the bank at some varying time throughout the day. The algorithm…

12

Asynchrony in C# 5.0 part Four: It’s not magic

Today I want to talk about asynchrony that does not involve any multithreading whatsoever. People keep on asking me “but how is it possible to have asynchrony without multithreading?” A strange question to ask because you probably already know the answer. Let me turn the question around: how is it possible to have multitasking without…

31

Asynchrony in C# 5, Part Three: Composition

I was walking to my bus the other morning at about 6:45 AM. Just as I was about to turn onto 45th street, a young man, shirtless, covered in blood ran down 45th at considerable speed right in front of me. Behind him was another fellow, wielding a baseball bat. My initial thought was “holy…

51

Asynchronous Programming in C# 5.0 part two: Whence await?

I want to start by being absolutely positively clear about two things, because our usability research has shown this to be confusing. Remember our little program from last time? async void ArchiveDocuments(List<Url> urls){  Task archive = null;  for(int i = 0; i < urls.Count; ++i)  {    var document = await FetchAsync(urls[i]);    if (archive != null)     …

161

Asynchrony in C# 5, Part One

The designers of C# 2.0 realized that writing iterator logic was painful. So they added iterator blocks. That way the compiler could figure out how to build a state machine that could store the continuation – the “what comes next” – in state somewhere, hidden behind the scenes, so that you don’t have to write…

61