Coder Social home page Coder Social logo

Comments (4)

PawelGerr avatar PawelGerr commented on June 14, 2024

Good point! It is a common issue when using synchronization mechanisms (like Thread.Wait(), Thread.Result or Task.GetAwaiter().GetResult()) in environments having synchronization contexts without thread pools (like web service or WPF app).

Here is a good explanation about that https://msdn.microsoft.com/en-us/magazine/jj991977.aspx

Best practice for a lib would be to add ConfigureAwait(false) to all async methods but that is kind of a moral conflict because I want the lib to be free of custom logic as possible.
Better solution if I stop awaiting Tasks in my code so that the caller (i.e you) can decide whether to configure the awaiter to continue on captured context or not.

My current code of GetAsync

public async Task<IHttpResponseMessage> GetAsync(string requestUri)
{
	return (await _client.GetAsync(requestUri)).ToInterface();
}

After change

public Task<IHttpResponseMessage> GetAsync(string requestUri)
{
	return _client.GetAsync(requestUri)
		.ContinueWith(task => task.Result.ToInterface());
}

If you have time you can make a pull request :) otherwise I will do that in the near future.

from thinktecture.abstractions.

PawelGerr avatar PawelGerr commented on June 14, 2024

@JoeDM09 try out the new version 1.3.3

from thinktecture.abstractions.

JoeDM09 avatar JoeDM09 commented on June 14, 2024

@PawelGerr Awesome, I'll pull it in and give it a try but I'm pretty sure this will fix my particular issue. I vaguely understand how the deadlock scenario happens but didn't know how to give instructions to replicate.

from thinktecture.abstractions.

JoeDM09 avatar JoeDM09 commented on June 14, 2024

Just a quick update to confirm this works as expected. Thanks for the quick turn around.

from thinktecture.abstractions.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.