title: Updating the UI with Xamarin
body: <p>I am having difficulty updating the UI using Xamarin. The objective is to make reactive UI so the user knows that application is thinking. Below are my attempts.</p>
  
  <p><strong>Attempt 1</strong></p>
  
  <pre><code>private void BeginProcess(string fileName)
  {
       Device.BeginInvokeOnMainThread(() =&gt; {
           iContent.Text = "UI Successfully updated.";
       });
  
       Device.BeginInvokeOnMainThread(() =&gt; {
           ProccessFolder testMethod = new ProccessFolder.Initialize(fileName);
       });
  }
  </code></pre>
  
  <p><strong>Attempt 2</strong></p>
  
  <pre><code>private void UpdateUI () {
      iContent.Text = "UI Successfully updated.";
  }
  
  private void BeginProcess(string fileName)
  {
       System.Threading.Thread t = new System.Threading.Thread(UpdateUI);
       t.Priority = System.Threading.ThreadPriority.Highest;
       t.IsBackground = false;
       t.Start();
  
       Device.BeginInvokeOnMainThread(() =&gt; {
           ProccessFolder testMethod = new ProccessFolder.Initialize(fileName);
       });
  }
  </code></pre>
  
  <p><strong>Attempt 3</strong></p>
  
  <pre><code>private void BeginProcess(string fileName)
  {
       Device.BeginInvokeOnMainThread(() =&gt; {
           iContent.Text = "UI Successfully updated.";
       });
  
       Task.Delay(5000);
  
       Device.BeginInvokeOnMainThread(() =&gt; {
           ProccessFolder testMethod = new ProccessFolder.Initialize(fileName);
       });
  }
  </code></pre>
  
  <p>Unfortunately none of these work. What does work is if I place the <strong>ProcessFolder</strong> method in a background thread and invoke the UI changes on the main thread. However the completion time of the <strong>ProcessFolder</strong> method is slower.</p>
  
  <p>Any suggestion on how I can update the UI while still executing <strong>ProcessFolder</strong> on the main thread?</p>