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

Tweak SaveChangesAsync_accepts_changes_with_ConfigureAwait_true_22841 #27019

Merged
1 commit merged into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SingleThreadSynchronizationContext : SynchronizationContext, IDispo
public SingleThreadSynchronizationContext()
{
Thread = new Thread(WorkLoop);
Thread.IsBackground = true;
Thread.Start();
}

Expand Down
4 changes: 4 additions & 0 deletions test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9053,6 +9053,10 @@ public async Task SaveChangesAsync_accepts_changes_with_ConfigureAwait_true_2284
var origSynchronizationContext = SynchronizationContext.Current;
SynchronizationContext.SetSynchronizationContext(trackingSynchronizationContext);

// Do a dispatch once to make sure we're in the new synchronization context. This is necessary in case the below happens
// to complete synchronously, which shouldn't happen in principle - but just to be safe.
await Task.Delay(1).ConfigureAwait(true);

bool? isMySyncContext = null;
Action callback = () => isMySyncContext =
SynchronizationContext.Current == trackingSynchronizationContext
Expand Down