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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:04:24+00:00 2026-05-24T01:04:24+00:00

In my program, there will be a time where I have to call Thread.Sleep(Timeout.Infinite);

  • 0

In my program, there will be a time where I have to call

Thread.Sleep(Timeout.Infinite);

to “temporarily pause” the BackgroundWorker. A groupbox will be shown before the backgroundworker thread sleeps. That groupbox has a button that should “wake up” the backgroundworker thread and continue it.

If I call Thread.Interrupt() (which by the way I can’t seem to use unless I create a Thread object, which I shouldn’t do) at the button_Click event, like:

private void button1_Click(object sender, EventArgs e)
    {
        Thread.Interrupt(); //interrupt thread
    }

The Thread it “would” interrupt is the UI Thread, am I right? What I need to do is to Interrupt the BackgroundWorker thread. How do I do this?

EDIT: Thanks for those that replied to this question. I’ll use AutoResetEvent. Seems more appropriate for my use.

  • 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-24T01:04:25+00:00Added an answer on May 24, 2026 at 1:04 am

    Let me start with the high-level concept:

    What you should do is have a token that you check every so often in the code that is being executed by the BackgroundWorker. When the token is set your background code will stop the normal flow and just check the token every now and then and when the token is cleared the background code can continue processing.

    So the interesting part above is the token. What I would do is maybe have a boolean that I check and when that boolean is set to true I would block the thread by waiting on ManualResetEvent. When you want to resume the processing you set the boolean to false and use the Set() method of the ManualResetEvent to release allow the code to continue.

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

Sidebar

Related Questions

I have a program that does the following: Call webservice (there are many calls
Is there a program that will print a nicely formatted tree from XML data?
Does there exist a free Windows software program that will help you generate regular
I remember there existed a testing program/library that will run your code and/or unit
Hey there. I'm trying to write a small program that will read the four
I have a program, and in that program there is some variables (username and
I have been working on a childish little program: there are a bunch of
I am writing a program which will manipulate certain objects, let's call them Words.
Are there any programs that will allow you to follow a sql transaction through
Is there a program or API I can code against to extract individual files

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.