title: Access UI without hang
body: <p>One of the method in my program access UI elements continuously and writes a file. This makes my UI stuck for sometime. I need to play a loading gif image during this time. But the image appears only after the task is completed.</p>
  
  <p>How do i change this code so that my app will without hanging UI?</p>
  
  <pre><code>private void BCreate_Click(object sender, RoutedEventArgs e)
  {
      ImgLoading.Visibility = Visibility.Visible;
      Thread newWindowThread = new Thread(new ThreadStart(RegUser));
      newWindowThread.Start();
  }
  
  private void RegUser()
  {
      this.Dispatcher.Invoke((Action)(() =&gt;
      {
          //method body
           .....           
          ImgLoading.Visibility = Visibility.Hidden;
      }));
  }
  </code></pre>