Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Advice regarding the Invoke method and background worker

$
0
0

Hi Everyone,

I've got a situation where I have a form, the form constructor is passed parameters which the constructor then uses to load up a report to the control which is on that form.

The problem is that the report takes time to load so what I have done is put the report code (which does some preparation and then calls the report form constructor) into the background worker so that the UI stays responsive.

The question I have is that, firstly, can I invoke this report form by it's constructor? The reason I ask this is because I want the form to be called on it's original thread so that I can avoid crossthreading problems.

Secondly, if I did invoke this, would it effectively make the background worker not have any work to do? The original thread would do all of the work thus rendering the background worker useless?

The problem I've got currently is that the constructor is not invoked but I'm getting errors about cross threading. I've invoked a method which sets the Form.MDIParent of the report form and I've invoked a Form.Show method also but I'm getting an error about the report viewer control being accessed from another thread but I don't understand this because I'm not doing anything to that control - the Show() invoke should be doing that.

I'm really confused. Help!

Antony


:D


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>