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
Resultproperty of theTask<T>type blocks the calling thread, so aWaitis not required. With the firstWriteLineafter starting the task, there's also not aWait, and the result is shown.What's better than using the
Resultproperty is to use theawaitkeyword. This doesn't block the calling thread.