Gigi
Gigi

Reputation: 29421

Does Task<T>.Result block if the task is Completed?

Accessing the Result property of a task has the potential to block until the task is complete, as Stephen Cleary's article on the subject demonstrates.

I imagine that accessing Result on a task that has already completed will never block, but I have not been able to find any source that confirms that. Is that so?

Upvotes: 0

Views: 275

Answers (1)

Giorgi
Giorgi

Reputation: 30873

From Task.Result Property documentation:

The get accessor for this property ensures that the asynchronous operation is complete before returning. Once the result of the computation is available, it is stored and will be returned immediately on later calls to Result.

Upvotes: 5

Related Questions