I am following this blogpost by @StephenHaunts here https://stephenhaunts.com/2014/10/10/simple-async-await-example-for-asynchronous-programming/#comments
What is the purpose of last return statement in the code, inside LongRunningOperation.
private static async Task<string> LongRunningOperation()
{
int counter;
for (counter = 0; counter < 50000; counter++)
{
Console.WriteLine(counter);
}
return "Counter = " + counter;
}
Now what I know is:
As I am calling this
LongrunningOperationinsideTask.Run, it should return whatever this awaited method is returning by default. Then Why it is not doing that.If I use
Task.Resultproperty then It'll run behave synchronously and block calling thread, which is not recommended.
What I want to ask is:
How I'll get this returned value printed at calling spot?
And why @Stephen have written that statement when there is no need of it?
Thanks in advance.