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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:39:54+00:00 2026-05-11T00:39:54+00:00

In my code, when a button is clicked the progress bar is set to

  • 0

In my code, when a button is clicked the progress bar is set to marquee and then my BackgroundWorker is called but when the BackgroundWorker is called the progress bar freezes or disappears. I use the BackgroundWorker to seperate the RefreshReport method of the ReportViewer from the UI thread. Any help is appreciated. Thanks!

    Private Sub btnOtherReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOtherReport.Click         rvReport.ProcessingMode = ProcessingMode.Remote         rvReport.ShowParameterPrompts = False         rvReport.ServerReport.ReportServerUrl = New Uri('REPORT_SERVER_URL')         rvReport.ServerReport.ReportPath = 'REPORT_PATH'         rvReport.BackColor = Color.White          BackgroundWorker1.RunWorkerAsync()     End Sub       Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork         RefreshReport()     End Sub       Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted         pbReports.Style = ProgressBarStyle.Blocks         pbReports.Value = 100     End Sub       Public Sub RefreshReport()         rvReport.BeginInvoke(New MethodInvoker(AddressOf rvReport.RefreshReport))     End Sub 
  • 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. 2026-05-11T00:39:55+00:00Added an answer on May 11, 2026 at 12:39 am

    The problem is when you call .BeginInvoke() in your RefreshReport() method. The BackgroundWorker.DoWork() method is already raised in a different thread, so you can just call rvReport.RefreshReport(). It should look like this:

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

    It really is that simple, with the possible addition of using a Monitor to lock your report object and prevent re-entry.

    Right now, when you call .BeginInvoke() the report process kicks off, but it doesn’t block at all so there’s nothing left for the DoWork() method to do. It just returns right away. At this point the BackgroundWorker thinks it’s done, so calls the .RunWorkerCompleted() method, which stops your progress bar.


    Based on the comment, rvReport is a visual control rather than a component or simple data access class. In that case, you should know that visual controls in .Net are not thread safe, and therefore should never directly do anything directly that takes more than a few moments to complete. The hoops you were jumping through with .BeginInvoke() in the RefreshReport() method had the effect of calling your long running function in the main UI thread.

    To solve this problem, you need to either turn off cross thread checking so that the exception is not thrown (simple, but not recommended) or change how you use the control, so that the main work happens elsewhere and the control just raises events when things are ready. If you can’t modify the control to that extent, it’s a design flaw in the control.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your selector is looking for any descendants of a checkbox… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer If these are all code you created, the best way… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer You can use GPG's symmetric option to encrypt files with… May 11, 2026 at 11:34 pm

Related Questions

First off let me just say I'm very new to coding so there are
I have created two forms in my Windows Application. One Form acts as a
I need to pass exceptions across a thread boundary. I'm using python embedded in
I started using the jquery ui library to add some enhanced UI elements to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.