Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConfigureAwait(false) when enumerating IAsyncEnumerable #3436

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Apr 5, 2024

This PR qualms the complaints the EnsureWarningsAreEmittedWhenProjectReferencingLibraries tests when I run it locally, and it's in-line with our existing practice of using .ConfigureAwait(false) in Aspire.

Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@karolz-ms karolz-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for DCP-related parts, thanks!

@ReubenBond ReubenBond merged commit 114c0ba into main Apr 5, 2024
8 checks passed
@ReubenBond ReubenBond deleted the rebond/iasyncenumerable-configureawait-false branch April 5, 2024 21:02
@@ -47,7 +47,7 @@ internal async Task SetLogSourceAsync(IAsyncEnumerable<IReadOnlyList<ResourceLog
var cancellationToken = await _cancellationSeries.NextAsync();
var logParser = new LogParser();

await foreach (var batch in batches.WithCancellation(cancellationToken))
await foreach (var batch in batches.WithCancellation(cancellationToken).ConfigureAwait(false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug @ReubenBond, see #3459

@@ -105,7 +105,7 @@ async Task TrackResourceSnapshotsAsync()

_resourceSubscriptionTask = Task.Run(async () =>
{
await foreach (var changes in subscription.WithCancellation(_resourceSubscriptionCancellation.Token))
await foreach (var changes in subscription.WithCancellation(_resourceSubscriptionCancellation.Token).ConfigureAwait(false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't a problem since Task.Run doesn't capture the sync context.

@@ -39,7 +39,7 @@ public ResourceOutgoingPeerResolver(IDashboardClient resourceService)
await RaisePeerChangesAsync().ConfigureAwait(false);
}

await foreach (var changes in subscription.WithCancellation(_watchContainersTokenSource.Token))
await foreach (var changes in subscription.WithCancellation(_watchContainersTokenSource.Token).ConfigureAwait(false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are problematic in UI code generally.

@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants