Docs: Does ConfigureAwait(false) make sense for async streams?

Created on 16 Aug 2019  Â·  2Comments  Â·  Source: dotnet/docs

The examples with await foreach do not show if ConfigureAwait can be used.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - C# Guide Technology - C# What's New .NET Core 3.0 P1 doc-enhancement

Most helpful comment

It does make sense, and it can be used. But because the underlying tasks returned from MoveNextAsync and DisposeAsync aren't directly available, you employ ConfigureAwait using the ConfigureAwait extension method on IAsyncEnumerable<T>:
https://github.com/dotnet/corefx/blob/f9c848d6ad5415c1fa844f5403ea8ef78c408f9a/src/System.Threading.Tasks/ref/System.Threading.Tasks.cs#L78
e.g.
C# await foreach (var item in source.ConfigureAwait(false)) { ... }

All 2 comments

That's a good question @lostmsu

@stephentoub Do you have guiidance here? Are there overloads that match the needed signatures?

It does make sense, and it can be used. But because the underlying tasks returned from MoveNextAsync and DisposeAsync aren't directly available, you employ ConfigureAwait using the ConfigureAwait extension method on IAsyncEnumerable<T>:
https://github.com/dotnet/corefx/blob/f9c848d6ad5415c1fa844f5403ea8ef78c408f9a/src/System.Threading.Tasks/ref/System.Threading.Tasks.cs#L78
e.g.
C# await foreach (var item in source.ConfigureAwait(false)) { ... }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebagomez picture sebagomez  Â·  3Comments

ygoe picture ygoe  Â·  3Comments

stanuku picture stanuku  Â·  3Comments

Manoj-Prabhakaran picture Manoj-Prabhakaran  Â·  3Comments

svick picture svick  Â·  3Comments