Skip to content

Commit

Permalink
Tweak SaveChangesAsync_accepts_changes_with_ConfigureAwait_true_22841 (
Browse files Browse the repository at this point in the history
…#27019)

To attempt to remove the flakiness
  • Loading branch information
roji authored Dec 16, 2021
1 parent c4b80ff commit 3489669
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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

0 comments on commit 3489669

Please sign in to comment.