I had a standard foreach loop which I later turned into a Parallel.Foreach(). However in my loop I have areas where I access the UI elements and get and set the UI elements info.
So when I run it I get an error that I cannot access the element as another thread has access to it. There are multiple elements I need to access and the x:Name are stored in the list.
How do I get past this?
Parallel.ForEach(calculatedTestVariables, variable =>
        {
            string idName = "id_" + variable.id;
            var textBox = this.FindName(idName) as TextBox; //need the text from this TextBox
            //some calculations
            int x = 1 + 2 + 3 + 4
            textBox.Text = x.toString();
        });
 
    
