Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Programming Asynchronously

Part of the 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.
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!