Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ConfigureAwait(false) in a Windows Service?

As far as I know, there isn't a synchronization context in a Windows Service application.

  • Does await fooTask.ConfigureAwait(false) give me any benefits in Windows Services?
  • Are there any pitfalls to this?
like image 319
annemartijn Avatar asked May 07 '14 08:05

annemartijn


1 Answers

Does await fooTask.ConfigureAwait(false) give me any benefits in Windows Services? Are there any pitfalls to this?

There is no pitfalls, for as long as there is no code which would install a synchronization context. There is no benefits either, for as long as this code runs on a thread without synchronization context.

Nevertheless, this code still would make sense for a shared class library, aimed to be used in different execution environments.

If you did have a synchronization context, there might be some pitfalls.

Updated: it's now 2021 and here's what I think about using ConfigureAwait these days.

like image 90
noseratio Avatar answered Oct 10 '22 22:10

noseratio