Use sleep() method to pause a thread for a specific period of time. - CSharp Thread Asynchronous

CSharp examples for Thread Asynchronous:Thread

Description

Use sleep() method to pause a thread for a specific period of time.

using System;
using System.Threading;

   class ThreadCreationProgram {

      public static void CallToChildThread() {
         Console.WriteLine("Child thread starts");
         int sleepfor = 5000;
         Console.WriteLine("Child Thread Paused for {0} seconds", sleepfor / 1000);
         Thread.Sleep(sleepfor);
         Console.WriteLine("Child thread resumes");
      }

      static void Main(string[] args) {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
   }
}

Related Tutorials