Skip to content

Should we call Wait method when we call Result property in Tasks? C# Parallel Programming #169

Answered by christiannagel
ShervanN asked this question in Q&A

You must be logged in to vote

It's page 451 in the book. The text in the book also mentions that the Result property of the Task<T> type blocks the calling thread, so a Wait is not required. With the first WriteLine after starting the task, there's also not a Wait, and the result is shown.

What's better than using the Result property is to use the await keyword. This doesn't block the calling thread.

Replies: 1 comment

You must be logged in to vote
0 replies
Answer selected by ShervanN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants