C# program to print elapsed milliseconds of stopwatch using Thread.Sleep() method

Today we are going to discuss this important topic via this article C# program to print elapsed milliseconds of stopwatch using Thread.Sleep() method. We hope you like this article.

C# program to print elapsed milliseconds of stopwatch using Thread.Sleep() method

C# program to print elapsed milliseconds of stopwatch using Thread.Sleep() method

/*
 * Program to print elapsed milliseconds of Stopwatch 
 * using Thread.Sleep() method in C#
 */

using System;
using System.Diagnostics;
using System.Threading;

class Program
{
    static void Main()
    {
        Stopwatch watch = Stopwatch.StartNew();
        
        Thread.Sleep(2000);
        watch.Stop();

        Console.WriteLine("Elapsed Milliseconds by ThreadSleep() :"+watch.ElapsedMilliseconds);
    }
}
Elapsed Milliseconds by ThreadSleep() :1999
Press any key to continue . . .

Final Words

C# program to print elapsed milliseconds of stopwatch using Thread.Sleep() method We learned about this very clearly through this article. And if you liked this article please share it with your friend.

Hi, I'm Selva a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment