title: How to handle return values in async function
body: <p>When working on data APIs which use async rest calls (I am using RestSharp.Portable), what is the best way to handle return values? Since async function can only return a Task or Task ... but the caller has no way to getting back to the return value ... how would the API return data back to the caller? Global properties? </p>
  
  <p>From what I have read so far, it appears that callback functions are the only way to interact with Response Data? </p>
  
  <p>Take the following method for example; previously I was not using async Rest library and was able to return a value but after converting it to use RestSharp.Portable, I dont see a way to return the value:</p>
  
  <pre><code>public async Task&lt;EntityResourceDescriptor&gt; GetEntityDescriptor(string entityType)
      {
          TaskCompletionSource&lt;EntityResourceDescriptor&gt; tcs = new TaskCompletionSource&lt;EntityResourceDescriptor&gt;();
          var req = new RestRequest("/qcbin/rest/domains/{domain}/projects/{project}/customization/entities/{entityType}");
          AddDomainAndProject(req);
          req.AddParameter("entityType", entityType, ParameterType.UrlSegment);
          client.ExecuteAsync&lt;EntityResourceDescriptor&gt;(req, (res) =&gt;
              {
                  if (res.ResponseStatus == ResponseStatus.Error)
                  {
                      tcs.TrySetException(res.ErrorException);
                  }
                  else
                  {
                      tcs.SetResult(res.Data);
                  }
              }
          );
          return tcs.Task;
      }
  </code></pre>
  
  <p>Here all I can do is return Task but the caller still has no way to get to the response data or am I missing something obvious? Can the caller subscribe to an event which gets fired at Task.Completed etc.?</p>
  
  <p>I am very fuzzy on this async concept. Are there any examples of writing Portable data APIs? </p>