title: Update progress bar in MainWindow from a different Thread
body: <p>I know this question has been asked several times an I spent all day trying to understand other answers, but since I am very new to C# and WPF nothing helped me so far. I will try to explain my exact problem as much as I can so it will directly help me.</p>
  
  <p>In my MainWindow.xaml I have a progress bar and some button starting a new thread and a long calculation:</p>
  
  <pre><code>&lt;ProgressBar Height="....... Name="progressBar1"/&gt;
  &lt;Button Content="Button" Name="button1" Click="button1_Click" /&gt;
  </code></pre>
  
  <p>Now within my MainWindow.xaml.cs:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          Thread thread = new Thread(new ParameterizedThreadStart(MyLongCalculation));
  
          ParameterClass myParameters = new ParameterClass();
          thread.Start(myParameters);
      }
  
      public void MyLongCalculations(object myvalues)
      {
          ParameterClass values = (ParameterClass)myvalues;
          //some calculations
      }
  }
  
  public class ParameterClass
  {
      //public variables...
  }
  </code></pre>
  
  <p>Now somehow I have to include somethign in my method MyLongCalculations that will keep updating <code>progressBar1</code>. However, I just can't manage to get it working.
  I know all this is very simple, but unfortunately it is the level I am at the moment on with C# so I hope an answer not too complicated and as detailed as possible would be great.</p>