How do I set a thread to a daemon thread in C#?
Asked
Active
Viewed 1.1k times
34
-
6http://meta.stackexchange.com/questions/17463/should-i-ask-a-question-i-know-the-answer-to – Epaga Feb 17 '11 at 14:30
2 Answers
54
Though you have already answered your own question, I would still like to elaborate more on it.
In C# .NET, unlike in Java
C# Background threads ~ Java Daemon threads
C# Foreground threads ~ Java User threads
By default, threads you create explicitly are foreground
threads.
"Background threads are identical to foreground threads, except that background threads do not prevent a process from terminating." (reference)
You can make a thread Daemon by
thread.IsBackground = true;

Paul Du Bois
- 2,097
- 1
- 20
- 31

Saurabh Gokhale
- 53,625
- 36
- 139
- 164
-
excellent, thanks! :) and re: answering my own question, see http://meta.stackexchange.com/questions/17463/should-i-ask-a-question-i-know-the-answer-to – Epaga Feb 19 '11 at 17:15