From cfcab31cea15f674291484086e4eb4c4d1c44ddb Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Thu, 2 May 2024 12:21:47 +1000 Subject: [PATCH] Support restoring a null initial synchronisation context --- .../Utilities/SynchronizationContextUtil.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Utilities/SynchronizationContextUtil.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Utilities/SynchronizationContextUtil.cs index ec846aa78d..e41391e9e7 100644 --- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Utilities/SynchronizationContextUtil.cs +++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Utilities/SynchronizationContextUtil.cs @@ -33,13 +33,13 @@ public static IDisposable Suppress() private sealed class SuppressionReleaser(SynchronizationContext old) : IDisposable { - private SynchronizationContext? old = old; + private int _isDisposed; public void Dispose() { - if (Interlocked.Exchange(ref old, null) is { } restoreMe) + if (Interlocked.Exchange(ref _isDisposed, 1) is 0) { - SynchronizationContext.SetSynchronizationContext(restoreMe); + SynchronizationContext.SetSynchronizationContext(old); } } }