I see a lot of people in blog posts and here on SO either avoiding or advising against the usage of the Thread
class in recent versions of C# (and I mean of course 4.0+, with the addition of Task
& friends). Even before, there were debates about the fact that a plain old thread's functionality can be replaced in many cases by the ThreadPool
class.
Also, other specialized mechanisms are further rendering the Thread
class less appealing, such as Timer
s replacing the ugly Thread
+ Sleep
combo, while for GUIs we have BackgroundWorker
, etc.
Still, the Thread
seems to remain a very familiar concept for some people (myself included), people that, when confronted with a task that involves some kind of parallel execution, jump directly to using the good old Thread
class. I've been wondering lately if it's time to amend my ways.
So my question is, are there any cases when it's necessary or useful to use a plain old Thread
object instead of one of the above constructs?