Why does the async keyword exist

It was introduced mainly to avoid backward compatibility issues. If the async-ness of a method must be inferred by the compiler (that would be through the detection of await keywords), then there are subtle scenarios where existing code would suddenly be treated differently, notably when you have identifiers (variable or function names called await). A … Read more

Using async-await on .net 4

Microsoft released the Async Targeting Pack (Microsoft.Bcl.Async) through Nuget as a replacement for the AsyncCTP. You can read more about it here: http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx. You can read about the previous version here: http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx. As this pack is officially supported, I now believe the best option for targeting XP + async would be using Visual Studio 2012 … Read more

What’s the difference between returning void and returning a Task?

SLaks and Killercam’s answers are good; I thought I’d just add a bit more context. Your first question is essentially about what methods can be marked async. A method marked as async can return void, Task or Task<T>. What are the differences between them? A Task<T> returning async method can be awaited, and when the … Read more

How to call an async method from a getter or setter?

There is no technical reason that async properties are not allowed in C#. It was a purposeful design decision, because “asynchronous properties” is an oxymoron. Properties should return current values; they should not be kicking off background operations. Usually, when someone wants an “asynchronous property”, what they really want is one of these: An asynchronous … Read more