title: Xamarin Forms, using async to apply ListView ItemSource
body: <p>I am currently using Xamarin Forms and I am using the <code>post</code> method which I got from github <a href="https://github.com/lab11/vlc-localization/blob/master/apps/winphone/CameraExplorer/PreviewPage.xaml.cs" rel="nofollow">RESTAPI</a>. My application crashes whenever I try to apply the data to my ListView ItemsSource.</p>
  
  <p>The following is the success callback that is currently executed, and it retrieves the JSON and serialize it and storing it in a list called listData.</p>
  
  <pre><code>public class Home : ContentPage
  {
      private ListView myListView;
      private List&lt;Person&gt; listInfo = new List&lt;Person&gt; { };
  
      RESTAPI rest = new RESTAPI();
      Uri address = new Uri("http://localhost:6222/testBackEnd.aspx");
  
      public Home ()
      {
          Dictionary&lt;String, String&gt; data = new Dictionary&lt;String, String&gt;();
          rest.post(address, data, success, null);
  
          Content = new StackLayout { 
              Children = 
              {
                  myListView
              }
          };
      }
  
      public void success(Stream stream)
      {
          DataContractJsonSerializer sr = new DataContractJsonSerializer(typeof(List&lt;Person&gt;));
          listData = (List&lt;Person&gt;)sr.ReadObject(stream);
          //myListView.ItemsSource = listData;
      }
  }
  </code></pre>
  
  <p>Is it because it is not asynchronous, and if so how can I make this method asynchronous? I did one previously on Windows Phone 8.1 using the following await code, is there a Xamarin Forms equivalent available for it?</p>
  
  <pre><code>async public void success(Stream stream)
  {
      DataContractJsonSerializer sr = new DataContractJsonSerializer(typeof(List&lt;Person&gt;));
      listData = (List&lt;Person&gt;)sr.ReadObject(stream);
      await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt;
      {
          myListView.ItemsSource = listData;
      });
  }
  </code></pre>