简体   繁体   English

为什么C#中的线程数大于1

[英]Why number of Threads is more than 1 in C#

I am working on Parallel processing project. 我正在从事并行处理项目。 One of the tasks is getting the number of threads for the current running process. 任务之一是获取当前正在运行的进程的线程数。

I am using this method: 我正在使用这种方法:

  private void timer1_Tick(object sender, EventArgs e)
  {
            label1.Text = Process.GetCurrentProcess().Threads.Count.ToString();
  }

But it gives me a very strange result, which is (13) !! 但这给了我一个非常奇怪的结果,那就是(13)! , however I have only one thread which is the UIThread and it should be (1) and I have not created any extra threads yet.. ,但是我只有一个线程是UIThread,应该是(1),并且我还没有创建任何额外的线程。

Can anyone explain that result for me? 谁能为我解释这个结果? Any help is appreciated 任何帮助表示赞赏

Every .NET application creates and maintains Thread Pool by default. 默认情况下,每个.NET应用程序都会创建和维护线程池。 You can limit it's size via ThreadPool.SetMaxThread method, but you must understand consequences of it. 您可以通过ThreadPool.SetMaxThread方法限制它的大小,但是您必须了解它的后果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM