March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System; using System.Threading; namespace Samples { public class ThreadStateSample { public static void StartHere() { Console.WriteLine("Thread: starting"); Thread.Sleep(1000); Thread t = Thread.CurrentThread; Console.WriteLine("ThreadState: {0}", t.ThreadState); for(int i = 0; i < 40; i++) Console.Write("."); Console.WriteLine(); Thread.Sleep(1000); Console.WriteLine("Thread: finishing"); } public static void Main() { Thread t = new Thread( new ThreadStart(StartHere)); Console.WriteLine("1) Thread state: {0}", t.ThreadState); t.Start(); Thread.Sleep(100); Console.WriteLine("2) Thread state: {0}", t.ThreadState); t.Suspend(); Console.WriteLine("3) Thread state: {0}", t.ThreadState); Thread.Sleep(1000); Console.WriteLine("4) Thread ...Read now
Unlock full access