tmenier / AsyncPoco

A long-"awaited" fully asynchronous PetaPoco fork
Other
127 stars 33 forks source link

Use ConfigureAwait(false) for all awaits #59

Closed DSaunders closed 5 years ago

DSaunders commented 5 years ago

To avoid deadlocks when forced to block on async code (for example, when migrating from a mostly synchronous codebase to async/await), and for performance reasons, it would be helpful to add ConfigureAwait(false) wherever await is used (Async/Await - Best Practices in Asynchronous Programming).

Was it a deliberate decision not to use ConfigureAwait(false), or would you be open to a PR adding this to all async calls?

tmenier commented 5 years ago

No, it wasn't deliberate. I would accept a PR.

I still would never recommend using AsyncPoco unless all calls are made synchronously (stick with PetaPoco or something else in that case). Also note that if you're using ASP.NET Core, ConfigureAwait doesn't matter because there is no SynchronizationContext. That said, no argument that it's still considered a best practice for libraries.

tmenier commented 5 years ago

Sorry for the delay. Looks good to me, I'll get it released. Thanks!

tmenier commented 5 years ago

This has been released and published to NuGet in 2.0.2

DSaunders commented 5 years ago

Thank you! 👍