How C#5 “await” works?

Let’s we have the following method that’s contain await keyword. The way the compiler will rewrite this its take the first half (marked as red), it’s splitting your method in to halfway see’s the await keyword and identifying first half of the code and second half will be the following code (marked it as green).
1
And then rewrites in to the following
2
In this first half of the code running synchronously in your method and the second half inside the continue with callback. If you are not in C#5 you can write code like that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s