Sunday 3 December 2017

C# Program to Implement Sleep method of Thread


Code:

using System;
using System.Diagnostics;
using System.Threading;
class Program
{
    static void Main()
    {
        var stopwatch = Stopwatch.StartNew();
        Thread.Sleep(500);
        stopwatch.Stop();
        Console.WriteLine("Elapsed Milliseconds : {0}",stopwatch.ElapsedMilliseconds);
        Console.WriteLine("Elapsed Ticks : {0}", stopwatch.ElapsedTicks);
        Console.WriteLine("Present Date and Time : {0}",DateTime.Now.ToLongTimeString());
        Console.ReadLine();
    }
}


Output:

Elapsed Milliseconds : 498
Elapsed Ticks : 1231409
Present Date and Time : 8:36:06 PM


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...