Why number of Threads is more than 1 in C#

2019-07-15 01:13发布

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) !!, however I have only one thread which is the UIThread and it should be (1) and I have not created any extra threads yet..

Can anyone explain that result for me? Any help is appreciated

1条回答
beautiful°
2楼-- · 2019-07-15 01:35

Every .NET application creates and maintains Thread Pool by default. You can limit it's size via ThreadPool.SetMaxThread method, but you must understand consequences of it.

查看更多
登录 后发表回答