List threads for PID : Thread Creation « Thread « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;

using System.Diagnostics;

  class Program
  {
    static void Main(string[] args)
    {

      Process theProc = null;
      try
      {
        theProc = Process.GetProcessById(12344);
      }
      catch
      {
        Console.WriteLine("-> Sorry...bad PID!");
        return;
      }
      Console.WriteLine("Here are the threads used by: {0}",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);
      }
    }
  }








20.1.Thread Creation
20.1.1.Thread method with parameter
20.1.2.Thread method with no parameter
20.1.3.The creation of threads
20.1.4.Create a thread of execution
20.1.5.Create multiple threads of execution
20.1.6.Passing an argument to the thread method.
20.1.7.Use anonymous delegate as the worker method to create Thread
20.1.8.Adding with Thread objects
20.1.9.Communicating Data to a Thread
20.1.10.Primary Thread statistcs
20.1.11.Starting a Method in a Separate Thread
20.1.12.Thread Stats
20.1.13.List threads for PID