If a method is declared as 'async', when we call that method, we can use await or not use it. I want to know when to use it and what's the effect of use it.
The async keyword is just an indicator to the compiler that the method may contain an await statement.
There's an interesting post by Eric Lippert explaining the design choice
Requiring "async" means that we can eliminate all backwards compatibility problems at once; any method that contains an await expression must be "new construction" code, not "old work" code, because "old work" code never had an async modifier.
http://blogs.msdn.com/b/ericlippert/archive/2010/11/11/whither-async.aspx
The marked async method typically use await to designate suspension points. The await operator tells the compiler that the async method can't continue past that point until the awaited asynchronous process is complete. In the meantime, control returns to the caller of the async method.
in another words if you are doing asyncronius programming and want to run certain thread task simultaniusly you would want to rely on async and await
more detailed explanations are here
http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With