Subscribe to How-To Geek

Get a List of Threads in a Process

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);
}
| More
This article was originally written on 11/23/06 Tagged with: Programming

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:

Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Our Friends
Getting Started


About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
mDNSResponder.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
conhost.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.