Task Parallel
While all this is important, there are cases where this solution lacks enough flexibility, and that's why we include Task Parallel Library in the set of the software tools available.
We've seen the basics of the Task
object in Chapter 3, Advanced Concepts of C# and .NET, and Chapter 12, Performance, but now it's time to look at some more advanced aspects that make this object one of the most interesting in .NET Framework regarding parallel programming.
Communication between threads
As you know, the results obtained after task completions can be of any type (Generics included).
When you create a new Task<T>
object, you inherit several methods and properties to facilitate data manipulation and retrieval. For example, you have properties such as Id
, IsCancelled
, IsCompleted
, IsFaulted
, and Status
to determine the state of the task and a Result
property, which contains the returning value of the task.
As for the methods available, you have a Wait
method to force the Task
object...