Sunday, 3 December 2017

C# Program to Pause a Thread


Code:

using System;
using System.Threading;
class Example
{
    static void Main()
    {
        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine("Sleep for 2 Seconds");
            Thread.Sleep(2000);
        }

        Console.WriteLine("Main thread Exits");
        Console.ReadLine();
    }
}


Output:

Sleep for 2 Seconds
Sleep for 2 Seconds
Sleep for 2 Seconds
Sleep for 2 Seconds
Sleep for 2 Seconds
Sleep for 2 Seconds
Main thread Exits


More C# Programs:





















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...