Should we call Wait method when we call Result property in Tasks? C# Parallel Programming #169
-
Hi, In chapter 17 Parallel Programming, Page 541, You wrote:
Should we call the Wait method when we call the Result property? In my opinion, we don't need it.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's page 451 in the book. The text in the book also mentions that the What's better than using the |
Beta Was this translation helpful? Give feedback.
It's page 451 in the book. The text in the book also mentions that the
Result
property of theTask<T>
type blocks the calling thread, so aWait
is not required. With the firstWriteLine
after starting the task, there's also not aWait
, and the result is shown.What's better than using the
Result
property is to use theawait
keyword. This doesn't block the calling thread.