Hi normally I would do this with a Background Worker, but I would like to do it with C# Task instead, just to understand Task better.
The thing is that I have a clas
I checked this: Task Parallelism (Task Parallel Library) and it it states that when using System.Threading.Tasks.Task
the Tasks run asynchronously and may complete in any order. If Result is accessed before the computation completes, the property will block the thread until the value is available.
I think that means if you are accessing .Result
before it has a value, as you are doing in your sample code, you will have to wait for it to complete first.
It does make sense as the Result
property would not be populated until the Task is completed.