Use ConfigureAwait(false) in a Windows Service?
Q

1

11

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?
Quintanilla answered 7/5, 2014 at 8:26 Comment(3)
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. It still makes sense for a shared class library.Lochia
@Noseratio Why don't you post that as an answer?Niu
@svick, I now posted it.Lochia
L
7

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.

Lochia answered 7/5, 2014 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.