Threads in Current Process : Process : Development C# Examples


C# Examples » Development » Process »

 

Threads in Current Process









    
using  System;
using  System.Diagnostics;

class  MainClass
{
      public  static  void  Main()
      {
            Process  thisProc  =  Process.GetCurrentProcess();
            ProcessThreadCollection  myThreads  =  thisProc.Threads;

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



Output

thread:  4064
    started: 25/03/2007 2:25:08 PM
    CPU time: 00:00:00.0312500
    priority: 8
    thread state: Running
thread:  440
    started: 25/03/2007 2:25:08 PM
    CPU time: 00:00:00
    priority: 8
    thread state: Wait
thread:  2444
    started: 25/03/2007 2:25:08 PM
    CPU time: 00:00:00
    priority: 10
    thread state: Wait


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Process