我应该如何创建一个后台线程? [英] How should I create a background thread?
本文介绍了我应该如何创建一个后台线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由下创建的线程是前台线程
发workingThread =新主题(新ParameterizedThreadStart(DoJob));
我可以使创建的线程的背景?
解决方案
是的,可以; System.Threading.Thread
有一个<一个href="http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx"><$c$c>IsBackground$c$c>属性。
获取或设置一个值,指示线程是否是后台线程。
发workingThread =新主题(新ParameterizedThreadStart(DoJob))
{的IsBackground = TRUE};
The thread created by the following is the foreground thread
Thread workingThread = new Thread(new ParameterizedThreadStart(DoJob));
Can I make the thread created background?
解决方案
Yes, you can; System.Threading.Thread
has an IsBackground
property.
Gets or sets a value indicating whether or not a thread is a background thread.
Thread workingThread = new Thread(new ParameterizedThreadStart(DoJob))
{ IsBackground = true };
这篇关于我应该如何创建一个后台线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文