Mega Code Archive

 
Categories / C# Tutorial / Thread
 

Foreground Thread Sleep

using System; using System.Threading; public class MainClass {     private static void MyFunction() {         Thread.Sleep( 5000 );         Console.WriteLine( "Exiting extra thread" );     }     static void Main() {         Thread thread1 = new Thread( new ThreadStart(MyFunction) );         thread1.Start();         Console.WriteLine( "Exiting main thread" );     } } Exiting main thread Exiting extra thread