title: C# ContinueWith / Return
body: <p>I'm a bit new to async programming in C#, and struggling with a small but frustrating challenge.</p>
  
  <p>I have a ASP.Net MVC WEB API that runs nicely. on the other side I have created this WEB API client method:</p>
  
  <pre><code>public async Task&lt;DTOVArt&gt; GetVArtFormArt(DTOArt art)
      {
          using (var client = GetHttpClient())
          {
              var response = await client.GetAsync("api/APIVArt/Get/" + art.ART_ID);
              if (!response.IsSuccessStatusCode) return null;
              var arts = await response.Content.ReadAsAsync&lt;DTOVArt&gt;();
              return arts;
          }
      }
  </code></pre>
  
  <p>which seems to be work very fine...</p>
  
  <p>This method is called from a WPF view model, an that's where my problem comes..</p>
  
  <pre><code>private DTOVObs TransFormAaretsGang(DTOAaretsGang aaretsGang)
      {
          var dtovObs = new DTOVObs();
  
          using (var artservice = new ArtService())
          {
              artservice.GetVArtFormArt(new DTOArt() {ART_ID = aaretsGang.ART_ID}).ContinueWith(t =&gt;
              {
                  dtovObs.Familie_id = t.Result.Familie_id;
                  dtovObs.Gruppe_id = t.Result.Gruppe_id;
                  dtovObs.ART_ID = t.Result.ART_ID;
                  if (aaretsGang.Dato != null) dtovObs.Aarstal = aaretsGang.Dato.Value.Year;
                  return dtovObs;
              });
          }
  
          return dtovObs;
      }
  </code></pre>
  
  <p>The problem is that this last methods performs the return statement before it hits the ContinueWith statement block, that actually sets the values inside the class that should be returned.</p>
  
  <p>Any attempt to do any kind of Wait() or using .Result instead of ContinueWith just blocks everything.</p>
  
  <p>And if I do the return inside the ContinueWith block, the C# compiler says the method is missing a return statement, which is true.</p>