The calling thread cannot access this object because a different thread owns it.
I got this error message when I was implementing BackgroundWorker in my WPF application. This error message got caught when I tried to access a dropdownlist value in the ‘DoWork’ event of worker process. So, instead of accesing the controls directly in ‘DoWork’ event, I passed the necessary values as arguments in the RunWorkerAsync method. Invoking the RunWorkerAsync method calls the ‘DoWork’ event. So, the result code is as follows,
object args = new object;
args = cmbGender.SelectedValue;
args = cmbState.SelectedValue;
args = cmbCountry.SelectedValue;
and, in the ‘DoWork’ method, I will get the parametes and use them as shown below,
void bgWorker_DoWork(object sender, DoWorkEventArgs e
var args = e.Argument as object;
if (Convert.ToInt32(args) != 0)
this will solve the issue.