Async CTP – Task based asynchronous programming for Windows Phone

6 code samples for this post

[my apps for Windows Phone that use Async CTP Smile]

Intro

Asynchronous programming is super-interesting especially today, with responsiveness required by all modern devices. In the context of Windows Phone 7, Async CTP Version 3 was released last year, and it’s compatible with SDK 7.1, Silverlight 5 and Roslyn CTP. Our takeaways today is using async in the context of Windows Phone 7, understanding TAP (task based asynchronous programming). I’ll show you how deep the rabbit hole goes: we’ll go beyond basics to exceptions, cancellations, progress, switching threads, combinators and even re-entrancy.

Historical Background

And let me just say: it’s worth learning NOW, because this model is quickly becoming mainstream, especially with Windows 8 not that far on the horizon. In terms of the where we are with Async CTP Version 3: you don’t need to wait for C# 5.0 to start using it. It has been a long time since 1960s when Steve Russel was one of the first to add continuations to LISP on IBM 704. I like this definition of continuations:

Say you’re in the kitchen in front of the refrigerator, thinking about a sandwich. You take a continuation right there and stick it in your pocket. Then you get some turkey and bread out of the refrigerator and make yourself a sandwich, which is now sitting on the counter. You invoke the continuation in your pocket, and you find yourself standing in front of the refrigerator again, thinking about a sandwich. But fortunately, there’s a sandwich on the counter, and all the materials used to make it are gone. So you eat it. :-)

Scheme formally introduced call/cc operations.

Continue reading “Async CTP – Task based asynchronous programming for Windows Phone”