title: WPF Best practice for async property
body: <p>Let's suppose I have a long running Web API call (async method) which returns a string.</p>
  
  <p>Is there a best practice between those 2 solutions to display the result in a WPF property without blocking UI ? Or is there another one ?</p>
  
  <p>Note: both solutions are not freezing UI and I already view posts <a href="https://stackoverflow.com/questions/6602244/how-to-call-an-async-method-from-a-getter-or-setter">How to call an async method from a getter or setter?</a> and <a href="https://stackoverflow.com/questions/12384309/async-property-in-c-sharp">Async property in c#</a>.</p>
  
  <h2>My Wep API</h2>
  
  <pre><code>private async Task&lt;string&gt; GetAsyncProperty()
  {
      string result = "Async Property Value";
  
      // Web api call...
      await Task.Delay(TimeSpan.FromSeconds(10));
  
      return result;
  }
  </code></pre>
  
  <h2>Solution A</h2>
  
  <p>XAML:</p>
  
  <pre><code>&lt;TextBlock Text="{Binding Path=AsyncPropertyA, UpdateSourceTrigger=PropertyChanged}" /&gt;
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>public MyConstructor()
  {
      Task task = SetAsyncPropertyA();
  }
  
  private async Task SetAsyncPropertyA()
  {
      this.AsyncPropertyA = await GetAsyncProperty().ConfigureAwait(false);
  }
  </code></pre>
  
  <h2>Solution B</h2>
  
  <p>XAML:</p>
  
  <pre><code>&lt;TextBlock Text="{Binding Path=AsyncPropertyB, UpdateSourceTrigger=PropertyChanged, IsAsync=True, FallbackValue='Loading B...'}" /&gt;
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>public string AsyncPropertyB
  {
      get
      {
          return GetAsyncPropertyB();
      }
  }
  
  private string GetAsyncPropertyB()
  {
      return Task.Run(() =&gt; GetAsyncProperty()).Result;
  }
  </code></pre>
  
  <p>Note: in solution B, I can add FallbackValue that's not working in solution A and potentially some other UI updates in ContinueWith of the Task.Run.</p>