Thread.ThreadState : Thread « System.Threading « C# / C Sharp by API






Thread.ThreadState

  
using System;
using System.Threading;

class MainClass
{
  static void MyThreadProc()
  {
    Thread.CurrentThread.Name = "TheSecondaryThread";
    Thread secondaryThread = Thread.CurrentThread;
    Console.WriteLine("Name? {0}", secondaryThread.Name);
    Console.WriteLine("Alive? {0}", secondaryThread.IsAlive);
    Console.WriteLine("Priority? {0}", secondaryThread.Priority);      
    Console.WriteLine("State? {0}", secondaryThread.ThreadState);
    Console.WriteLine();

    for(int i = 0; i < 1000; i ++)
    {
      Console.WriteLine("Value of i is: {0}", i);
      Thread.Sleep(5);
    }
  }

  [MTAThread]
  static void Main(string[] args)
  {
    Thread secondaryThread = new Thread(new ThreadStart(MyThreadProc));
    secondaryThread.Priority = ThreadPriority.Highest;
    
    secondaryThread.IsBackground = true;
    secondaryThread.Start();
  }
}

   
    
  








Related examples in the same category

1.new Thread()
2.Thread.Abort()
3.Thread.AllocateDataSlot
4.Thread.AllocateNamedDataSlot
5.Thread.CurrentContext
6.Thread.CurrentCulture
7.Thread.CurrentThread
8.Thread.GetData
9.Thread.GetHashCode()
10.Thread.Interrupt()
11.Thread.IsAlive
12.Thread.IsBackground
13.Thread.Join()
14.Thread.Priority
15.Thread.ResetAbort()
16.Thread.SetData
17.Thread.Sleep
18.Thread.Start