The System.Diagnostics namespace contains functions that allow you to manage processes, threads, eventlogs and performance information.

The System.Diagnostics.Process object gives you access to functionality enabling you to manage system processes and threads.


Add this line to your using list:

using System.Diagnostics;

You can get a list of ProcessThreads in a process by using the Process.Threads property, which returns a ProcessThreadCollection object.

Here’s a code example for you, assuming that you already have a Process object named theProcess.


ProcessThreadCollection threadlist = theProcess.Threads;

foreach(ProcessThread theThread in threadlist){
   Console.WriteLine("Thread ID:{0} Priority: {1} Started: {2}", 
  theThread.Id, theThread.PriorityLevel, theThread.StartTime);
Lowell Heddings Lowell Heddings
Lowell is the founder and CEO of How-To Geek. He’s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work.
Read Full Bio »

The above article may contain affiliate links, which help support How-To Geek.