C# Program to Implement Sleep Method of Thread


This is a C# Program to implement sleep method of thread.

Problem Description

This C# Program Implements Sleep method of Thread.

Problem Solution

Here Sleep pauses programs. It receives a value indicating the number of milliseconds to wait.

Program/Source Code

Here is source code of the C# Program to Implement Sleep method of Thread. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

 * C# Program to Implement Sleep method of Thread
using System;
using System.Diagnostics;
using System.Threading;
class Program
    static void Main()
        var stopwatch = Stopwatch.StartNew();
        Console.WriteLine("Elapsed Milliseconds : {0}",
        Console.WriteLine("Elapsed Ticks : {0}", stopwatch.ElapsedTicks);
        Console.WriteLine("Present Date and Time : {0}",
Program Explanation

In this C# Program, the Sleep() function is used to pauses program. It receives a value indicating the number of milliseconds to wait. Then ElapsedMilliseconds() function is used to print the Elapsed Milliseconds. The ElapsedTicks() function is used to print the Elapsed Ticks. The ToLongTimeString() function is used to print the Present Date and Time.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
Runtime Test Cases
Elapsed Milliseconds : 498
Elapsed Ticks : 1231409
Present Date and Time : 8:36:06 PM

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go toC# Programs.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.