Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:38:42+00:00 2026-05-29T05:38:42+00:00

I have a code which when run, it executes series of lines in sequence.

  • 0

I have a code which when run, it executes series of lines in sequence.
I would like to add a pause in between.

Currently, I have it like this

//do work
Thread.Sleep(10800000);
//do work

This however freezes the software, and I think it’s because sleep time is way too long.
I searched online and I found another work around called Timer.
Can someone show me a sample code for Timer which works just like Thread.sleep?

Thank you in advance.

Edit : I need the software to wait for 3 hours before proceeding with rest of the code execution. This software is meant to communicate with machines, and I cannot let the rest of the code execute while waiting for 3 hours.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:38:43+00:00Added an answer on May 29, 2026 at 5:38 am

    Your software would freeze if that sleep is on the main thread. Keep in mind the parameter is in milliseconds. 10 800 000 milliseconds = 10 800 seconds

    Another way to pass the time is to pass a TimeSpan object instead. Ex:

    // Sleep for 10 seconds
    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 10));
    

    As for timer:

    You can use System.Timers.Timer;

    Timer timer = new Timer();
    timer.Interval = 20; // milliseconds
    timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
    timer.AutoReset = true; // if not set you will need to call start after every event fired in the elapsed callback
    timer.Start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question concerning this code which I want to run on QNX:
I have code which needs to do something like this There is a list
I have VBScript code which launches QuickTest Professional, executes a series of QTP tests,
I have the following sample code which doesn't seem to want to run. import
I have the following code, which is run every 10ms as part of a
I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) {
This is my code I have developed. This is the main program which holds
I have a C# application which generates .NET functions at run-time and executes them.
I have the code below which loops through selected checkboxes and executes and sql
I have some C# code which formats a MS Project file. This code works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.