Follow-up to this question. I have a library with many async methods that thinly wrap HttpClient
. Effectively they just do some setup and directly return the Task
returned from the HttpClient
call:
public Task DoThingAsyc() {
// do some setup
return httpClient.DoThingAsync();
}
I'm pondering whether to add ConfigureAwait(false)
to these calls. The prevailing wisdom seems to be "yes, always do that in libraries." But in this case, it would introduce some (perhaps negligible) overhead, because ConfigureAwait
returns a ConfiguredTaskAwaitable
which would need to be wrapped back into a Task
in order to not change the method signature. Certainly not hard to code:
public async Task DoThingAsyc() {
// do some setup
return await httpClient.DoThingAsync().ConfigureAwait(false);
}
My question is, will the efficiency benefits of ConfigureAwait(false)
likely outweigh the extra overhead introduced in this case? What example above would be considered the better practice?