Comments (4)
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.
@JoeDM09 try out the new version 1.3.3
from thinktecture.abstractions.
@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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thinktecture.abstractions.