System.Threading.Task

Added in .NET 4.0
A Task represents an asynchronous operation.



Asynchronous implementation is easy in a task, using' async' and 'await' keywords.
A task can return a result
A task can have multiple processes happening at the same time.
A task can have multiple processes happening at the same time.
A task can support cancellation through the use of cancellation tokens

link - learn.microsoft.com/en-us/dotnet/standard/parallel-programming/ 
link - learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-parallel-library-tpl

These are much more powerful than the Backgroundworker
partitioning of the work,
taking care of state management,
scheduling threads on the thread pool,
using callback methods
enabling continuation or cancellation of tasks.


  • Data and task parallelism

  • Schedule threads in a thread pool

  • Ability to use all available cores

  • Cancellation of work

  • Partitioning of work


A task is a lightweight object that manages a parallelism unit of work
Tasks use the CLRs thread pool which avoids creating a new thread.





© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext