Skip to content

No use of await #214

@dotMorten

Description

@dotMorten

I've notice a lot of the code does some serious thread blocking, like for instance:

IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> responseOperation = client.PostAsync(uri, requestContent);
TaskAwaiter<HttpResponseMessage> responseAwaiter = responseOperation.GetAwaiter();
while (!responseAwaiter.IsCompleted)
{
}
using (HttpResponseMessage response = responseOperation.GetResults())
{
   ///...
}

Is there a reason await isn't just used instead? This loop would saturate the thread, and I think there's a potential of deadlock here, which would also explain why so often my requests are hanging and never return.

All the code above could be rewritten to:

using (HttpResponseMessage response = await client.PostAsync(uri, requestContent))
{
   ///...
}

I can make a PR to clean this all up, but the pattern is used throughout and I'm wondering if there was a reason for it?
@WilliamsJason @hpsin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions