18

Does Task.Result synchronously block current thread such that it cannot be used to perform other operations while it is waiting for the task complete?

For example, if I call Task.Result in a ASP.NET execution path, the current thread cannot be used to process other requests while it's awaiting the result.

By the way, how about the async in C# 5.0? Does await async method block the current thread?

Thanks for any comment.

Ricky
  • 34,377
  • 39
  • 91
  • 131
  • Guess that's the difference between `await F` and `F.Result`. One is async the other is not. – Emad Dec 26 '16 at 06:12
  • @Emad, yes I guess that too. However, I would like to find a formal document or more detailed explanation about it. – Ricky Dec 26 '16 at 06:27
  • Since you've obviously read [Task.Result](https://msdn.microsoft.com/en-us/library/dd321468(v=vs.110).aspx) documentation before asking the question I think some deeper explanation is needed - as provided by linked duplicate. – Alexei Levenkov Dec 26 '16 at 07:57

1 Answers1

21

MSDN: https://msdn.microsoft.com/en-us/library/dd321468(v=vs.110).aspx

Accessing the property's get accessor blocks the calling thread until the asynchronous operation is complete; it is equivalent to calling the Wait method

MSDN: https://msdn.microsoft.com/en-us/library/hh156528.aspx

An await expression does not block the thread on which it is executing

Lanorkin
  • 7,310
  • 2
  • 42
  • 60