How to

list process threads

Published: 9. October 2011 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Windows » Processes
Tags: C# Threading Windows
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Diagnostics;

Code

Process process = Process.GetCurrentProcess();
ProcessThreadCollection threads = process.Threads;

foreach (ProcessThread thread in threads)
{
    Console.WriteLine("Id: {0}", thread.Id);
    Console.WriteLine("Thread State: {0}", thread.ThreadState);
    Console.WriteLine("Priority Level: {0}", thread.PriorityLevel);
    Console.WriteLine("Start Time: {0}", thread.StartTime);
    Console.WriteLine("CPU time: {0}", thread.TotalProcessorTime);
}
Send us feedback about this snippet »



Related Snippets: