This is where it works:
public class ThisWorks : IPortableHttpClient
{
private Windows.Web.Http.HttpClient client;
async public Task<Windows.Web.Http.HttpResponseMessage> GetAsync(Uri url)
{
return await client.GetAsync(url);
}
And this does not work and I don't understand why:
public class DoesntWork : IPortableHttpClient
{
private Windows.Web.Http.HttpClient client;
async public Task<Windows.Web.Http.HttpResponseMessage> GetAsync(Uri url)
{
return await client.GetAsync(url);
}
This gets an error message: await client.GetAsync(url)
And the errormessage is this: 'IAsyncOperationWithProgress' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperationWithProgress' could be found (are you missing a using directive for 'System')?
If it matters, here is IPortableHttpClient:
public interface IPortableHttpClient
{
Task<HttpResponseMessage> GetAsync(Uri url);
}
Another information that could be useful: The code where it works is in a UWP framework. It does not work in a .NET framework.
Aucun commentaire:
Enregistrer un commentaire