Allows you to write a simple console application (debug mode):
static void Main(string[] args) { Process p = Process.GetCurrentProcess(); IList<Thread> threads = new List<Thread>(); Console.WriteLine(p.Threads.Count); for(int i=0;i<30;i++) { Thread t = new Thread(Test); Console.WriteLine("Before start: {0}", p.Threads.Count); t.Start(); Console.WriteLine("After start: {0}", p.Threads.Count); } Console.WriteLine(Process.GetCurrentProcess().Threads.Count); Console.ReadKey(); } static void Test() { for(int i=0;i<100;i++)Thread.Sleep(1); }
What do you think you'll see in the results?
[Q1] Why is p.Threads.Count different from Process.GetCurrentProcess (). Threads.Count?
source share