How should I implement ExecuteAsync with RestSharp on Windows Phone 7?

前端 未结 6 1433
忘掉有多难
忘掉有多难 2020-12-08 04:50

I\'m attempting to use the documentation on the RestSharp GitHub wiki to implement calls to my REST API service but I\'m having an issue with the ExecuteAsync method in part

6条回答
  •  北海茫月
    2020-12-08 05:01

    Since public static RestRequestAsyncHandle ExecuteAsync(this IRestClient client, IRestRequest request, Action callback) has been deprecated, you should look to using public Task ExecuteAsync(IRestRequest request, CancellationToken token = default) instead.

    The following code

    client.ExecuteAsync(request, response => { callback(response.Content); });
    

    Should instead become

    await client.ExecuteAsync(request).ContinueWith(task => callback(task.Result.Content));
    

提交回复
热议问题