title: How can I efficiently update the UI from an async method?
body: <p>I'm using a <code>ProgressBar</code> with binding to show the progress when receiving a file from a remote device.</p>
  
  <pre><code>&lt;ProgressBar Width="500" Height="50" Value="{Binding ProgressFileReceive}"/&gt;
  </code></pre>
  
  <p><code>ProgressFileReceive</code> is a property (<code>double</code>) in my View Model which has the percentage completion. So to update the Progress Bar, I add to this number.</p>
  
  <p>The problem is I have the file transfer method in a different <code>async</code> method, and so to access this property I must use the following code :</p>
  
  <pre><code>await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
     () =&gt;
     {
         // do something on the UI thread
         ProgressFileReceive = (double)i / fileSize * 100;
     });
  </code></pre>
  
  <p>This works but makes the whole process extremely slow, since at each iteration (there are over a thousand loops since I read byte-by-byte) the method has to use the dispatcher to update the UI. It takes several times longer to receive the whole file, than it would take if I was not updating the UI.</p>
  
  <p>How can I do this more efficiently so as to speed up the process ?</p>