StephenCleary / AsyncEx

A helper library for async/await.
MIT License
3.49k stars 358 forks source link

[Question] Is ConfigureAwait(false) is needed? #278

Closed deastr closed 1 year ago

deastr commented 1 year ago

Hi,

The samples doesn't use ConfigureAwait(false) but since I barely understand ConfigureAwait I wanted to make sure that I'm not doing something wrong: is ConfigureAwait(false) method needed any time while using AsyncLock/AsyncManuelResetEvent/AsyncSemaphore?

The code only uses async methods (no async/sync mix). There are async awaits inside the using scope of AsyncLock. It's not a library, it's application code.

StephenCleary commented 1 year ago

AsyncEx itself doesn't care.

The question of whether you should use ConfigureAwait is whether that method (the one with the configured await) needs its context or not. If it updates GUI controls or calls into ASP.NET (pre-Core) methods, then it would need its context resumed. Otherwise, you could use ConfigureAwait(false).