Thread is an operating system feature which let our application executes multiples operations at the same time.
Task is a feature introduced in .net 4.0. Task is simply represents an operation which need to be executed in separate thread.
In .net 4.0 TPL or task processing library is simple a set of API’s on top of core threading for simplifying threading.
How it simplifies?
When we work with core threading directly
- We have to make sure that all processor cores are used efficiently.
- Thread pooling is taken care - It means when large number of threads are required to be created threads will be kept into pool(instead of getting destroyed) once it’s done with operation so that it will be reused later.
How to work with tasks?
- Import System.Threading.Task Namespace.
- Creating Task object passing function name as parameter to constructor.
- Start the thread.
For online live trainings on various technical topics including WCF, MVC, Design Patterns, BI, WPF, VSTS Application life cycle management and every other technology visit www.sukesh-Mara.com or contact SukeshMarla@Gmail.com
Also click and see the following .NET/C# threading interview questions video on thread, background thread and foreground thread: -