When I call to the ProgressChanged
method I'm getting an InvalidOperationException
I found out on MSDN that this happens because the WorkerReportsProgress
is set to false
but it is set to true in my program.
This is the BW initializations:
bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.WorkerReportsProgress = true;
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
The call to the Progress:
tempNetwork.Nodes.Add(tempNode);
bw.ReportProgress(1, tempNetwork);
tempNetwork
is local