1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | using System; using System.Threading; namespace Threading { public class Program { protected static void threadFunction() { Console.WriteLine("Inside the thread. "); while (true) { Console.Write("." ); Thread.Sleep(400); } } static void Main(string[] args) { Thread lThread = new Thread(new ThreadStart(threadFunction)); lThread.Start(); Thread.Sleep(5000); lThread.Abort(); lThread.Join(); } } } |