You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code, which uses await Task.Run(() => { }).ConfigureAwait(false); to lose the synchronization context, was introduced in PR #528 as an attempt to fix the same issue occurring with the previous strategy using await Task.Delay(TimeSpan.FromMilliseconds(1)).ConfigureAwait(false);.
It appears that await Task.Run(() => { }).ConfigureAwait(false); works most of the time, but there's something going on which means that it doesn't always lose the synchronization context. Is it possible that it's still completing synchronously?
The text was updated successfully, but these errors were encountered:
That was exactly my thought - that it is clever enough to realise that executing the action synchronously is the most efficient thing to do, and as a result, just happens to retain the sync context. I guess we need to work out a more reliable mechanism to force this not to occur.
@crozone - Huge apologies for the ridiculously long time it has taken me to get around to fixing this. So much so that I've forgotten how to raise PRs and link to issues 🤣 #606
We are intermittently seeing test failures from an assertion within
Stateless.Tests.SynchronizationContextFixture.LoseSyncContext()
, for example:https://github.com/dotnet-state-machine/stateless/actions/runs/6823242739/job/18556789583
which failed with:
This code, which uses
await Task.Run(() => { }).ConfigureAwait(false);
to lose the synchronization context, was introduced in PR #528 as an attempt to fix the same issue occurring with the previous strategy usingawait Task.Delay(TimeSpan.FromMilliseconds(1)).ConfigureAwait(false);
.It appears that
await Task.Run(() => { }).ConfigureAwait(false);
works most of the time, but there's something going on which means that it doesn't always lose the synchronization context. Is it possible that it's still completing synchronously?The text was updated successfully, but these errors were encountered: