Programming Asynchronously - dummies

By Bill Sempf, Chuck Sphar, Stephen R. Davis

Part of C# 5.0 All-in-One For Dummies Cheat Sheet

A lot of Windows 8 is about being fast and fluid. The way to do this is by using asynchronous methods in callbacks from long running functionality. The problem with this is that in C#, the best way to implement an asynchronous method is with threading. But you can’t always depend on when the items from a threading operation will come back. There needs to be some control if you want the users to be able to feel like there is some control.

Enter async and await. async is used to declare an asynchronous function, which returns a Task. All async methods must contain at least one await expression. await tells C# to take referred code and run it in a separate thread than the user thread. The table breaks down the new asynchronous parts of the language.

Statement Description
async A modifier that shows the compiler that the function it
modifies is asynchronous.
await An operator that suspends the execution of the containing
method until the awaited task completes.
Task Represents an asynchronous operation.
Task<TResult> An asynchronous operation that returns a value.
Task.ContinueWith A continuation that is started after the operation in the Task
is completed.