So in my DoWork I have
List<KeyValuePair<String, BitmapImage>> Files = new List<KeyValuePair<string,BitmapImage>>((List<KeyValuePair<String, BitmapImage>>)e.Argument);
foreach (KeyValuePair<String, BitmapImage> i in Files)
{
string temp = i.ToString(); .......(1)
}
I pass the argument as follows: -
backgroundWorkerForReupload.RunWorkerAsync(files);
where "files" are of type List<KeyValuePair<string, BitmapImage>>
In line (1) above, he displays a message InvalidOperationExceptionwith the message: "The calling thread cannot access this object because it has a different thread."
I am confused why it ibelongs to another thread. Any help would be greatly appreciated. Thanks.
source
share