Enum Threads For Pid : ProcessThreadCollection : Thread C# Examples


C# Examples » Thread » ProcessThreadCollection »

 

Enum Threads For Pid









    
using  System;
using  System.Diagnostics;

class  MyProcessManipulator  {
        public  static  void  EnumThreadsForPid(int  pID)  {
                Process  theProc;
                try  {
                        theProc  =  Process.GetProcessById(pID);
                }  catch  {
                        return;
                }
                Console.WriteLine(theProc.ProcessName);
                ProcessThreadCollection  theThreads  =  theProc.Threads;
                foreach  (ProcessThread  pt  in  theThreads)  {
                        string  info  =  string.Format("->  Thread  ID:  {0}\tStart  Time  {1}\tPriority  {2}",
                        pt.Id,  pt.StartTime.ToShortTimeString(),  pt.PriorityLevel);
                        Console.WriteLine(info);
                }
        }
        static  void  Main(string[]  args)  {
                Console.Write("PID:  ");
                int  theProcID  =  int.Parse(Console.ReadLine());
                EnumThreadsForPid(theProcID);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» ProcessThreadCollection