List all process threads in current running processes : Process : Development C# Examples


C# Examples » Development » Process »

 

List all process threads in current running processes









    
using  System;
using  System.Diagnostics;

class  MainClass
{
      public  static  void  Main()
      {
            Process[]  allProcs  =  Process.GetProcesses();

            foreach(Process  proc  in  allProcs)
            {
                  ProcessThreadCollection  myThreads  =  proc.Threads;
                  Console.WriteLine("process:  {0},    id:  {1}",  proc.ProcessName,  proc.Id);

                  foreach(ProcessThread  pt  in  myThreads)
                  {
                        Console.WriteLine("    thread:    {0}",  pt.Id);
                        Console.WriteLine("        started:  {0}",  pt.StartTime.ToString());
                        Console.WriteLine("        CPU  time:  {0}",  pt.TotalProcessorTime);
                        Console.WriteLine("        priority:  {0}",  pt.BasePriority);
                        Console.WriteLine("        thread  state:  {0}",  pt.ThreadState.ToString());  
                  }
            }
      }
}
    
   
  
   



Output

process: explorer,  id: 1636
  thread:  1640
    started: 16/03/2007 8:42:07 PM
    CPU time: 00:01:31.1250000
    priority: 8
    thread state: Wait
  thread:  1932
    started: 16/03/2007 8:42:10 PM
    CPU time: 00:02:00.9062500
    priority: 9
    thread state: Wait
  thread:  1936
    started: 16/03/2007 8:42:10 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1944
    started: 16/03/2007 8:42:10 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1952
    started: 16/03/2007 8:42:11 PM
    CPU time: 00:02:51.6093750
    priority: 8
    thread state: Wait
  thread:  400
    started: 16/03/2007 8:42:17 PM
    CPU time: 00:00:10.0781250
    priority: 8
    thread state: Wait
  thread:  612
    started: 16/03/2007 8:42:24 PM
    CPU time: 00:00:00
    priority: 15
    thread state: Wait
  thread:  1696
    started: 16/03/2007 8:42:52 PM
    CPU time: 00:00:10
    priority: 10
    thread state: Wait
  thread:  2864
    started: 16/03/2007 8:44:36 PM
    CPU time: 00:42:13.9218750
    priority: 8
    thread state: Wait
  thread:  2868
    started: 16/03/2007 8:44:37 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  4032
    started: 20/03/2007 7:32:28 PM
    CPU time: 00:00:00.1250000
    priority: 8
    thread state: Wait
  thread:  208
    started: 23/03/2007 8:22:56 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  2684
    started: 23/03/2007 8:25:29 PM
    CPU time: 00:00:00.0312500
    priority: 8
    thread state: Wait
  thread:  2364
    started: 25/03/2007 12:20:21 PM
    CPU time: 00:00:14.2812500
    priority: 8
    thread state: Wait
  thread:  3964
    started: 25/03/2007 2:25:01 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
process: svchost,  id: 1064
  thread:  1068
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:00.6562500
    priority: 8
    thread state: Wait
  thread:  1088
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:00.0468750
    priority: 8
    thread state: Wait
  thread:  1092
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:00.0781250
    priority: 8
    thread state: Wait
  thread:  1096
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:39.6093750
    priority: 8
    thread state: Wait
  thread:  1100
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1132
    started: 16/03/2007 8:42:03 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1240
    started: 16/03/2007 8:42:04 PM
    CPU time: 00:00:00.0312500
    priority: 8
    thread state: Wait
  thread:  1548
    started: 16/03/2007 8:42:07 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1560
    started: 16/03/2007 8:42:07 PM
    CPU time: 00:00:00.1875000
    priority: 8
    thread state: Wait
  thread:  1688
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:00.0468750
    priority: 8
    thread state: Wait
  thread:  1692
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:02.0468750
    priority: 8
    thread state: Wait
  thread:  1700
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:01.5312500
    priority: 8
    thread state: Wait
  thread:  1704
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1708
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:00.2500000
    priority: 8
    thread state: Wait
  thread:  1772
    started: 16/03/2007 8:42:08 PM
    CPU time: 00:00:17
    priority: 8
    thread state: Wait
  thread:  1820
    started: 16/03/2007 8:42:10 PM
    CPU time: 00:01:06.7031250
    priority: 8
    thread state: Wait
  thread:  148
    started: 16/03/2007 8:42:15 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  380
    started: 16/03/2007 8:42:17 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  392
    started: 16/03/2007 8:42:17 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  396
    started: 16/03/2007 8:42:17 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  424
    started: 16/03/2007 8:42:18 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  628
    started: 16/03/2007 8:42:24 PM
    CPU time: 00:00:00.1093750
    priority: 8
    thread state: Wait
  thread:  1180
    started: 16/03/2007 8:42:25 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1184
    started: 16/03/2007 8:42:25 PM
    CPU time: 00:00:00.0781250
    priority: 8
    thread state: Wait
  thread:  1256
    started: 16/03/2007 8:42:26 PM
    CPU time: 00:00:01.0156250
    priority: 8
    thread state: Wait
  thread:  1288
    started: 16/03/2007 8:42:26 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1076
    started: 16/03/2007 8:42:26 PM
    CPU time: 00:00:00.0156250
    priority: 15
    thread state: Wait
  thread:  756
    started: 16/03/2007 8:42:26 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  812
    started: 16/03/2007 8:42:26 PM
    CPU time: 00:00:00.0312500
    priority: 8
    thread state: Wait
  thread:  1452
    started: 16/03/2007 8:42:29 PM
    CPU time: 00:00:01
    priority: 8
    thread state: Wait
  thread:  1456
    started: 16/03/2007 8:42:29 PM
    CPU time: 00:00:00.1093750
    priority: 8
    thread state: Wait
  thread:  1480
    started: 16/03/2007 8:42:33 PM
    CPU time: 00:00:00.0468750
    priority: 8
    thread state: Wait
  thread:  1516
    started: 16/03/2007 8:42:33 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1312
    started: 16/03/2007 8:42:33 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1080
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  940
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1160
    started: 16/03/2007 8:42:50 PM
    CPU time: 00:00:00.0156250
    priority: 9
    thread state: Wait
  thread:  1364
    started: 16/03/2007 8:42:50 PM
    CPU time: 00:00:00.0625000
    priority: 8
    thread state: Wait
  thread:  1048
    started: 16/03/2007 8:42:50 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1368
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00.9687500
    priority: 8
    thread state: Wait
  thread:  1372
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 9
    thread state: Wait
  thread:  1460
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 9
    thread state: Wait
  thread:  1404
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  968
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1536
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1496
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1488
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1500
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1860
    started: 16/03/2007 8:42:51 PM
    CPU time: 00:00:00.0468750
    priority: 8
    thread state: Wait
  thread:  2136
    started: 16/03/2007 8:42:52 PM
    CPU time: 00:00:00.0625000
    priority: 8
    thread state: Wait
  thread:  2148
    started: 16/03/2007 8:42:52 PM
    CPU time: 00:00:01.1406250
    priority: 8
    thread state: Wait
  thread:  2160
    started: 16/03/2007 8:42:53 PM
    CPU time: 00:00:00.5156250
    priority: 8
    thread state: Wait
  thread:  2304
    started: 16/03/2007 8:42:59 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1600
    started: 17/03/2007 8:42:08 AM
    CPU time: 00:00:01.6250000
    priority: 8
    thread state: Wait
  thread:  1972
    started: 17/03/2007 10:17:18 AM
    CPU time: 00:00:01.0156250
    priority: 8
    thread state: Wait
  thread:  1040
    started: 19/03/2007 7:39:40 PM
    CPU time: 00:00:00
    priority: 9
    thread state: Wait
  thread:  160
    started: 20/03/2007 6:05:14 AM
    CPU time: 00:00:01.9218750
    priority: 8
    thread state: Wait
  thread:  1024
    started: 20/03/2007 9:06:56 PM
    CPU time: 00:00:00.0781250
    priority: 8
    thread state: Wait
  thread:  3660
    started: 23/03/2007 8:42:51 PM
    CPU time: 00:00:00.1406250
    priority: 8
    thread state: Wait
  thread:  2072
    started: 24/03/2007 2:36:56 AM
    CPU time: 00:00:00.2031250
    priority: 8
    thread state: Wait
  thread:  732
    started: 25/03/2007 11:18:24 AM
    CPU time: 00:00:00.0781250
    priority: 8
    thread state: Wait
  thread:  3436
    started: 25/03/2007 11:37:24 AM
    CPU time: 00:00:00.0781250
    priority: 8
    thread state: Wait
  thread:  2016
    started: 25/03/2007 12:16:30 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  560
    started: 25/03/2007 12:18:49 PM
    CPU time: 00:00:00.1718750
    priority: 8
    thread state: Wait
  thread:  2856
    started: 25/03/2007 2:10:18 PM
    CPU time: 00:00:00.0468750
    priority: 8
    thread state: Wait
  thread:  2528
    started: 25/03/2007 2:14:25 PM
    CPU time: 00:00:00.0625000
    priority: 8
    thread state: Wait
  thread:  436
    started: 25/03/2007 2:16:38 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  3792
    started: 25/03/2007 2:17:12 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  4088
    started: 25/03/2007 2:17:12 PM
    CPU time: 00:00:00.0156250
    priority: 8
    thread state: Wait
  thread:  1828
    started: 25/03/2007 2:18:54 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  3148
    started: 25/03/2007 2:22:27 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  2320
    started: 25/03/2007 2:24:35 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
process: svchost,  id: 884
  thread:  888
    started: 16/03/2007 8:42:00 PM
    CPU time: 00:00:00.0312500
    priority: 8
    thread state: Wait
  thread:  908
    started: 16/03/2007 8:42:01 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  916
    started: 16/03/2007 8:42:01 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1000
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  944
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  948
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1988
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1984
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1980
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1996
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1992
    started: 16/03/2007 8:42:49 PM
    CPU time: 00:00:00.9062500
    priority: 8
    thread state: Wait
  thread:  2632
    started: 16/03/2007 8:44:10 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  3684
    started: 18/03/2007 4:15:30 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  3652
    started: 18/03/2007 4:15:30 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  1084
    started: 25/03/2007 9:31:28 AM
    CPU time: 00:00:00.0937500
    priority: 8
    thread state: Wait
  thread:  3008
    started: 25/03/2007 1:54:53 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
  thread:  3456
    started: 25/03/2007 2:12:34 PM
    CPU time: 00:00:00
^CTerminate batch job (Y/N)? n


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Process