What is async/await?
The async
and await
keywords were introduced in .NET 4.5 to make calling async methods easier and to make your async code more easily readable.
The async
/await
API is syntactic sugar that uses the TPL (Task Parallel Library) behind the scenes. If you wanted to start a new task and have code run on the UI thread after the task completes prior .NET 4.5, your code would have looked something like this:
Using async/await, the above code becomes just two lines of it.In the nutshell it does exactly the same thing.async
and await
keywords were introduced in .NET 4.5 to make calling async methods easier and to make your async code more easily readable. async
/await
API is syntactic sugar that uses the TPL (Task Parallel Library) behind the scenes. If you wanted to start a new task and have code run on the UI thread after the task completes prior .NET 4.5, your code would have looked something like this:The above code gets compiled behind the scenes to the same TPL code as it does in the first example, so as noted, this is just syntactic sugar, and how sweet it is!
No comments :
Post a Comment