Oleg Vazhnev
Oleg Vazhnev

Reputation: 24067

when to use Task and when to use Thread?

I've just asked question about Task but realized that I actually want to ask more general question. Could someone summarize pros and cons of Tasks and Threads. How to understand should I use Task or Thread?

Upvotes: 17

Views: 11756

Answers (1)

Tigran
Tigran

Reputation: 62246

Task is an order to program to do something in asynchronous way. The Thread is actually OS kernel object which executes what was requested. Think about Task like a clever thread aggregator/organizer that "knows" how much task is better to run contemporary on your CPU. It's just cleverer then common implementations of multi-threading (that's why it's suggested choice from Microsoft). It's a feature that helps you managing Threads in easier way.

Look also on this Should i use ThreadPools or Task Parallel Library for IO-bound operations that may give you some hints on performance issues you may be interested in.

Upvotes: 5

Related Questions