c# - Why does this simple .NET console app have so many threads? -


this simple program starts 15 threads - according count. during lifetime drops few, come back.

class program  {      static void main(string[] args)      {          while (true)          {              console.writeline(process.getcurrentprocess().threads.count);              thread.sleep(500);          }      }  } 

i expecting process have 1 thread (and intuition backed this)

without debugger, process has (!) 4 threads. surely clr stuff hidden process?

what count this? process have many threads? why?

try running outside debugger (i.e. press ctrl+f5 instead of f5). should see 3 threads - main thread, gc thread & finalizer thread iirc. other threads see debugger-related threads.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -