Home > Backend Development > C#.Net Tutorial > C# equivalent to Java's Thread.setDaemon?

C# equivalent to Java's Thread.setDaemon?

WBOY
Release: 2023-09-11 20:45:12
forward
1230 people have browsed it

C# equivalent to Javas Thread.setDaemon?

C# is equivalent to Java's Thread.setDaemon, which is the concept of foreground and background threads.

When the foreground thread is closed, the background thread will also terminate. Foreground threads continue to run until the last foreground thread terminates.

The property used for background threads is IsBackground, which gets or sets a value indicating whether the thread is a background thread. The default value for this property is false because the default thread created is the foreground thread.

To create a thread daemon in C#, use isBackground -

Thread bgThread = new Thread(tStart);
bgThread.IsBackground = true;
bgThread.Start();
Copy after login

The above is the detailed content of C# equivalent to Java's Thread.setDaemon?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template