I am currently trying to update a diagram that is in my background worker form using:
bwCharter.RunWorkerAsync(chart1);
What is done:
private void bcCharter_DoWork(object sender, DoWorkEventArgs e) { System.Windows.Forms.DataVisualization.Charting.Chart chart = null;
However, at the time of cleaning the series, an exception is thrown.
Basically, I want to do a lot more processing after cleaning the series, which completely slows down the GUI - I wanted it in another thread.
I thought that passing this as an argument, I should be safe, but apparently not!
Interestingly, the chart is on the tab. I can run it again and again if the tab is in the background, but if I run it, look at the chart, hide it again and run again, it throws an exception. Obviously, he throws if the chart is also in the foreground.
Can anyone suggest what I can do differently?
Thanks!
EDIT: I know this can be done as a stream, as when I return it again. However, the whole point of using a background worker is to avoid interrupting the entire program. As I said, processing is much more than this command.
I assumed that passing it as an argument would allow me to freely access it in this thread, but is there any chance that this graph traversed still indicates the original graph? If so, how can this be overcome?
I want to block the GUI thread as little as possible, so it makes no sense to just call each command.