开发者

C# equivalent to Java's Thread.setDaemon?

How do I 开发者_如何学运维set a thread to a daemon thread in C#?


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;  


Like this:

myThread.IsBackground = true; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜