C# equivalent to Java's Thread.setDaemon?
10,297
Solution 1
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;
Solution 2
Like this:
myThread.IsBackground = true;
Author by
Epaga
Java developer @ i-net software by day Indie iOS developer of Mindscope and In-Flight Assistant by night Husband of 1, dad of 4
Updated on June 18, 2022Comments
-
Epaga almost 2 years
How do I set a thread to a daemon thread in C#?