title: How to show progress during app startup in Xamarin Forms
body: <p>I have a Xamarin Forms app that needs to perform a sequence of long-running operations during startup. I would like to inform the user of progress, using a page with a simple status message which changes as the sequence progresses.</p>
  
  <p>The sequence of operations is implemented as a set of asynchronous methods, which I have wrapped in an async container method that also contains the code to update the UI. Here's a simplified version:</p>
  
  <pre><code>private async Task DoStartupSequence()
  {
      SetStatusMessage("Step 1");
      await DoStep1();
      SetStatusMessage("Step 2");
      await DoStep2();
      SetStatusMessage("Step 3");
      await DoStep3();
      SetStatusMessage("Completed");
  }
  </code></pre>
  
  <p>However, regardless of how I invoke the sequence, the UI doesn't get updated until execution of the sequence is complete.</p>
  
  <p>I have tried running the sequence on its own thread from within the <code>App</code> constructor:</p>
  
  <pre><code>public App()
  {
      InitializeComponent();
      Task.Run(() =&gt; DoStartupSequence()).Wait();
  }
  </code></pre>
  
  <p>I have also tried invoking the sequence asynchronously from within the <code>OnStart</code> method:</p>
  
  <pre><code>protected override async void OnStart()
  {
      await DoStartupSequence();
  }
  </code></pre>
  
  <p>In a WinForms app, this problem might be solved using <code>Application.DoEvents</code> (although I understand that this approach has its own problems). In any case, Xamarin Forms doesn't appear to support anything like this.</p>
  
  <p>This seems like such a common requirement that I imagine there must be a standard pattern for its implementation. Does anyone know what it is?</p>
  
  <p>Many thanks,</p>
  
  <p>Tim</p>
  
  <p><strong>Update</strong>: In response to suggestions from @BraveHeart, I am able to further simplify my test code to show what's not working properly. </p>
  
  <p>The following sample references 2 static pages, each containing just a label. The 1st page announces the start of a long-running sequence and the 2nd page announces its completion. My goal is to see these 2 pages rendered with a 1-second delay between the first and the second. In practice, what happens is that I never see page 1, because both pages are rendered together.</p>
  
  <pre><code>public App()
  {
      InitializeComponent();
  
      var navigationPage = new NavigationPage();
  
      MainPage = navigationPage;
  
      navigationPage.Navigation.PushAsync(new TestPage1(), false).Wait();
  
      Task.Delay(1000).Wait();
  
      navigationPage.Navigation.PushAsync(new TestPage2(), false).Wait();
  }
  </code></pre>