title: Using ASP.NET ReportViewer control in a background thread
body: <p>I have an application that renders around 100 reports as PDF's and saves them to the disk using asp.net Report Viewer control with SSRS 2008. I'm trying to run this method, called ProcessReports, in the background on a separate thread so the browser is not idle/does not time out (process takes around 10 minutes).</p>
  
  <p>When I start a new thread:</p>
  
  <pre><code>    Dim t As New Thread(AddressOf ProcessReports)
      t.Start()
  </code></pre>
  
  <p>I would like the main thread to display a progress message in a label</p>
  
  <pre><code>     lblMessage1.Visible = True
       lblMessage1.Text = "Processing..."
  </code></pre>
  
  <p>Problem: When the background thread runs the ProcessReports method and hits the ReportViewer control:</p>
  
  <pre><code>      ReportViewer1.ServerReport.ReportServerUrl = _
         New Uri("https://mysite.net/ReportServer")
      ReportViewer1.ServerReport.ReportPath = _
         "/mypath/My_Report"
  </code></pre>
  
  <p>The label never displays anything and I keep getting the following error message:</p>
  
  <pre><code>     Object reference not set to an instance of an object.
  </code></pre>
  
  <p>How do I get the ReportViewer control to work on a background thread while the main thread displays a progress message?</p>