Thursday, 11 February 2016

C Sharp Program how to use Sleep method of Thread

using System;
using System.Diagnostics;
using System.Threading;
class SleepMethod
{
    static void Main()
    {
        var stopwatch = Stopwatch.StartNew();
        Thread.Sleep(4000);
        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 : 3999
Elapsed Ticks : 12468015
Present Date and Time : 9:27:22 AM
-------------------------------------------

No comments:

Post a Comment