title: WPF UI Freezes - UI Thread conflict?
body: <p>I'm trying to create an image slideshow effect with  <code>WPF</code>.<br>
  The method to update the slideshow with a new image is called every few seconds in a <code>Windows.Forms.Timer</code>, and runs in it's own thread within a <code>Task</code> (as seen below).</p>
  
  <pre><code>private void LoadImage()
      {
          Task t = Task.Run(() =&gt;
          {    
             this.Dispatcher.BeginInvoke((Action)(() =&gt;
             {
                 TimeSpan delay = new TimeSpan(0, 0, 0, 0, 0);
                 Fader.ChangeSource(image, BitmapFromUri(new Uri(compPath + oComps[nCount].name)), delay, delay);
                 image.Visibility = System.Windows.Visibility.Visible;
  
                 mediaElement.Stop();
                 mediaElement.Close(); ;
                 mediaElement2.Stop();
                 mediaElement2.Close();
                 mediaElement.Visibility = System.Windows.Visibility.Collapsed;
                 mediaElement2.Visibility = System.Windows.Visibility.Collapsed;
  
                 imageLoop.Interval = oComps[nCount].duration;
  
                 nCount++;
  
                 imageLoop.Start();
             }));
          });
      }
  </code></pre>
  
  <p>Simultaneously, there is a scrolling text banner across the bottom of the canvas in an overlay. This too is running in it's own thread, updating the UI through a <code>Dispatcher</code>. <br><br>
  Every few images, both the scrolling text <em>and</em> the slideshow will pause for a second or two, seemingly waiting for the image to load. This behaviour is unexpected as each element is in a seperate thread.<br><br>
  <br>
  Could this be a conflict between the two Task threads updating the UI thread?<br>
  <strong>What could be causing this?</strong></p>