title: WinRT async data load in constructor
body: <p>I want to load some data in the constructor of a ViewModel but due to WinRT's async nature I am forced to use async methods. Unfortunately I cannot have an async constructor so I am trying to use the asynchronous method as a synchronous method. I'm sure there is a much better way of loading data (async) on application load but my mind is drawing a blank at the moment.</p>
  
  <p>I'm either looking for a way to fix my app using the line of thought i'm going down, or to fix this permanently using a more appropriate method.</p>
  
  <p>The code is very simple (even missing the ViewModel) just to demonstrate the issue I'm facing.</p>
  
  <pre><code>public sealed partial class MainPage : Page
  {
  
      public string Data { get; set; }
  
      public DataService _dataService { get; set; }
  
      public MainPage()
      {
          this.InitializeComponent();
  
          _dataService = new DataService();
          var t = _dataService.GetData();
  
          Data = t.Result;
      }
  
      /// &lt;summary&gt;
      /// Invoked when this page is about to be displayed in a Frame.
      /// &lt;/summary&gt;
      /// &lt;param name="e"&gt;Event data that describes how this page was reached.  The Parameter
      /// property is typically used to configure the page.&lt;/param&gt;
      protected override void OnNavigatedTo(NavigationEventArgs e)
      {
      }
  
  
  }
  
  public class DataService
  {
      public async Task&lt;string&gt; GetData()
      {
          //Force async
          await Task.Delay(1);
  
          return "Hello";
      }
  }
  </code></pre>
  
  <p>Kind Regards</p>