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 6840107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:48:01+00:00 2026-05-26T23:48:01+00:00

I have a Winform which needs to wait for about 3 – 4 hours.

  • 0

I have a Winform which needs to wait for about 3 – 4 hours. I can’t close and somehow reopen the App, as it does few things in background, while it waits.

To achieve the wait – without causing trouble to the UI thread and for other reasons -, I have a BackgroundWorker to which I send how many milliseconds to wait and Call Thread.Sleep(waitTime); in its doWork event. In the backGroundWorker_RunWorkerCompleted event, I do what the program is supposed to do after the wait.

This works fine on the development machine. i.e. the wait ends when it has to end. But on the Test machine, it keeps waiting for longer. It happened two times, first time it waited exactly 1 hour more than specified time and second time it waited more for about 2 Hours and 40 minutes.

Could there be any obvious reason for this to happen or am I missing something?

The dev machine is Win XP and Test machine is Win 7.

  • 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-26T23:48:02+00:00Added an answer on May 26, 2026 at 11:48 pm

    Have a look at this article which explains the reason:

    Thread.Sleep(n) means block the current thread for at least the number
    of timeslices (or thread quantums) that can occur within n
    milliseconds. The length of a timeslice is different on different
    versions/types of Windows and different processors and generally
    ranges from 15 to 30 milliseconds. This means the thread is almost
    guaranteed to block for more than n milliseconds. The likelihood that
    your thread will re-awaken exactly after n milliseconds is about as
    impossible as impossible can be. So, Thread.Sleep is pointless for
    timing.

    By the way it also explains why not to use Thread.Sleep 😉

    I agree to the other recommendations to use a Timer instead of the Thread.Sleep.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Winform app which lists a batch of invoices in a gridview.
I have a .net winforms app which has a few animation effects, fade ins
I have a winform app that needs to be aware of when a SQL
I have a Winform app that has a backgroundWorker thread and does all operations
I have a C# winform app which is doing a lot of calculation. there
I've got a VB.NET WinForms app in which I have the need to refer
I have a winform project which lists all the files in a specified folder.
I have a windows installer project which installs some software (winform, service, mce addin).
I have an MDI WinForms app in which the MDI parent form has a
I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There

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.