Simple Thread with ThreadStart : Thread Start « Thread « C# / CSharp Tutorial






using System;
using System.Threading;

class MainClass
{
  public static void DoCount()
  {
    for ( int i = 0; i < 10; i++ )
    {
      System.Console.WriteLine( "Reached {0}", i );
    }
  }

  [STAThread]
  static void Main(string[] args)
  {
    Thread t = new Thread( new ThreadStart( DoCount ) );
    t.Start();
  }
}
Reached 0
Reached 1
Reached 2
Reached 3
Reached 4
Reached 5
Reached 6
Reached 7
Reached 8
Reached 9








20.2.Thread Start
20.2.1.An alternate way to start a thread: start a thread in its own constructor
20.2.2.thread.IsAlive
20.2.3.Simple Thread with ThreadStart