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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:44:01+00:00 2026-05-25T02:44:01+00:00

I have seen this problem before but I haven’t seen an answer to the

  • 0

I have seen this problem before but I haven’t seen an answer to the question that applied to my particular case. I have a BackgroundWorker running in my VB form, as well as a progress bar and some labels. I also (if it’s important) have a WebBrowser on my form, but it isn’t affected by the thread.

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    Dim ints As Integer = Int(InputBox("What number to start at?"))
    Dim inte As Integer = Int(InputBox("What number to end at?"))
    ToolStripStatusLabel1.Text = "0 / " & inte - ints
    ToolStripProgressBar1.Maximum = inte
    ToolStripProgressBar1.Minimum = ints
    ToolStripProgressBar1.Style = ProgressBarStyle.Continuous
    Try
        For z As Integer = ints To inte

            ToolStripProgressBar1.Value = z
            ToolStripStatusLabel1.Text = z & "/" & inte
            'do some stuff here
    catch etc
    next

When the loop is running, sometimes it stops and the progress bar disappears. Any idea why?
Btw the only thing I’m doing in there is running an httpwebrequest and handling the string.

  • 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-25T02:44:02+00:00Added an answer on May 25, 2026 at 2:44 am

    This is likely to do with the fact that you’re setting the value of a user interface object (ToolStripProgressBar1) within the BackgroundWorker‘s DoWork method which is running in it’s own thread, separate from the User Interface thread which the ToolStripProgressBar1 is in.

    As per the Note on this MSDN page:

    You must be careful not to manipulate any user-interface objects in
    your DoWork event handler. Instead, communicate to the user interface
    through the ProgressChanged and RunWorkerCompleted events.

    BackgroundWorker events are not marshaled across AppDomain boundaries.
    Do not use a BackgroundWorker component to perform multithreaded
    operations in more than one AppDomain.

    What you should do is to change the code that’s inside the loop (For z As Integer = ints To inte) so that instead of setting the Value and Text properties directly, you call the BackgroundWorker‘s ReportProgress method. This raises the ProgressChanged event which you can then handle on the main UI thread. It’s in here that you can then safely access the properties of User Interface components and objects.

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

Sidebar

Related Questions

I've seen that a few instances of this problem have been raised already. However,
I have seen this macro defined before but never really knew its purpose. Can
I've seen this problem before but I'm not sure how to solve it. Say
I haven't seen this addressed yet, but I think that might be because I
I have seen this problem arise in many different circumstances and would like to
I have seen this syntax in MSDN: yield break , but I don't know
I have seen this question: Are there any decent UI components for touch screen
I have seen this question about deploying to WebSphere using the WAS ant tasks.
I've seen a couple of similar questions to this, but haven't been able to
I have problem with UpdateAllTasks activity. Before executing this activity, I have a task

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.