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'm passing the argument as follows :-
backgroundWorkerForReupload.RunWorkerAsync(files);
where "files" is of Type List<KeyValuePair<string, BitmapImage>>
At line (1) above, it throws an InvalidOperationException
with the message : "The calling thread cannot access this object because a different thread owns it."
I'm confused as to why i
is owned by another thread. Any help would be greatly appreciated. Thank you.