Tuesday 21 April 2015

Difference between async void ,async Task and async Task methods

1)Task<T>returning async method can be awaited, and when the task completes it will return up a T.

2)Task returning async method can be awaited, and when the task completes, the continuation of the task is scheduled to run.

3)void returning async method cannot be awaited; it is a "fire and forget" method. It does work asynchronously, and you have no way of telling when it is done.


The await expression means "evaluate this expression to obtain an object representing work that will in future produce a result. Sign up the remainder of the current method as the call back associated with the continuation of that task. Once that task is produced and the call back is signed up,immediately return control to my caller". This is opposed/in contrast to a regular method call, which means "remember what you're doing, run this method until it is completely finished and then pick up where you left off, now knowing the result of the method".

For more, check this msdn link.