960 references to CompareExchange
AnalyzerRunner (1)
Aspire.Hosting.Analyzers (1)
ClientSample (1)
dotnet-svcutil-lib (8)
GenerateDocumentationAndConfigFiles (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
InMemory.FunctionalTests (1)
Metrics (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Metrics.Legacy (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.AspNetCore.App.Analyzers (1)
Microsoft.AspNetCore.Components.WebAssembly (2)
Microsoft.AspNetCore.Cryptography.Internal (2)
Microsoft.AspNetCore.DataProtection (1)
Microsoft.AspNetCore.DataProtection.Extensions (1)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (1)
Microsoft.AspNetCore.Routing (1)
Microsoft.AspNetCore.Server.HttpSys (1)
Microsoft.AspNetCore.Server.IIS (3)
Microsoft.AspNetCore.Server.Kestrel.Core (1)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (2)
Microsoft.AspNetCore.Shared.Tests (1)
Microsoft.AspNetCore.SignalR.Client.Core (1)
Microsoft.Build (7)
Microsoft.Build.Framework (4)
Microsoft.Build.Tasks.Core (2)
Microsoft.CodeAnalysis (56)
Emit\CommonPEModuleBuilder.cs (7)
227if (Interlocked.CompareExchange(ref _lazyArrayMethods, result, null) != null)
886Interlocked.CompareExchange(ref NestedTypes, new ConcurrentQueue<Cci.INestedTypeDefinition>(), null);
978Interlocked.CompareExchange(ref defs.Methods, new ConcurrentQueue<Cci.IMethodDefinition>(), null);
991Interlocked.CompareExchange(ref defs.Properties, new ConcurrentQueue<Cci.IPropertyDefinition>(), null);
1004Interlocked.CompareExchange(ref defs.Fields, new ConcurrentQueue<Cci.IFieldDefinition>(), null);
1023Interlocked.CompareExchange(ref _lazySynthesizedNamespaceMembers, new ConcurrentDictionary<INamespaceSymbolInternal, ConcurrentQueue<INamespaceOrTypeSymbolInternal>>(), null);
1135if (Interlocked.CompareExchange(ref _lazyPrivateImplementationDetails, result, null) != null)
InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Syntax\SyntaxNode.cs (7)
146Interlocked.CompareExchange(ref field, green.CreateRed(this, this.GetChildPosition(slot)), null);
164Interlocked.CompareExchange(ref field, green.CreateRed(this, this.Position), null);
181Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.GetChildPosition(slot)), null);
199Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.Position), null);
222Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(slot)), null);
244Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(1)), null);
279if (Interlocked.CompareExchange(ref slot, newWeakReference, previousWeakReference) == previousWeakReference)
Microsoft.CodeAnalysis.Analyzers (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.AnalyzerUtilities (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.BannedApiAnalyzers (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.CodeStyle (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.Collections.Package (5)
Microsoft.CodeAnalysis.CSharp (181)
Compilation\CSharpCompilation.cs (10)
87Interlocked.CompareExchange(ref _conversions, new BuckStopsHereBinder(this, associatedFileIdentifier: null).Conversions, null);
1429Interlocked.CompareExchange(ref _lazyGlobalNamespace, result, null);
1495Interlocked.CompareExchange(ref _externAliasTargets, new ConcurrentDictionary<string, NamespaceSymbol>(), null);
1540Interlocked.CompareExchange(ref _lazyScriptClass, BindScriptClass()!, ErrorTypeSymbol.UnknownResultType);
1805Interlocked.CompareExchange(ref _lazyHostObjectTypeSymbol, symbol, null);
1913Interlocked.CompareExchange(ref _lazyEntryPoint, entryPoint, null);
2594binderFactories = Interlocked.CompareExchange(ref cachedBinderFactories, binderFactories, null) ?? binderFactories;
2622if (Interlocked.CompareExchange(ref slot!, newWeakReference, previousWeakReference) == previousWeakReference)
2641if (_lazyCompilationUnitCompletedTrees == null) Interlocked.CompareExchange(ref _lazyCompilationUnitCompletedTrees, new HashSet<SyntaxTree>(), null);
3231var recent = Interlocked.CompareExchange(ref _usageOfUsingsRecordedInTrees, updated, current);
Symbols\Metadata\PE\PENamedTypeSymbol.cs (13)
107return Interlocked.CompareExchange(ref _lazyUncommonProperties, result, null) ?? result;
400Interlocked.CompareExchange(ref uncommon.LazyExtensionParameter, new StrongBox<ParameterSymbol?>(extensionParameter), null);
458Interlocked.CompareExchange(ref uncommon.LazyImplementationMap, new ConcurrentDictionary<MethodSymbol, MethodSymbol?>(ReferenceEqualityComparer.Instance), null);
672Interlocked.CompareExchange(ref _lazyBaseType, MakeAcyclicBaseType(), ErrorTypeSymbol.UnknownResultType);
720Interlocked.CompareExchange(ref _lazyDeclaredBaseType, baseType, ErrorTypeSymbol.UnknownResultType);
1043Interlocked.CompareExchange(ref _lazyMemberNames, CreateReadOnlyMemberNames(names), null);
1453Interlocked.CompareExchange(ref uncommon.lazyEnumUnderlyingType, underlyingType, null);
1656var exchangeResult = Interlocked.CompareExchange(ref _lazyMembersByName, membersDict, null);
2002Interlocked.CompareExchange(ref _lazyUncommonProperties, new UncommonProperties(), null);
2005Interlocked.CompareExchange(ref _lazyUncommonProperties.lazyExtensionInfo, new ExtensionInfo(markerHandle), null);
2477Interlocked.CompareExchange(ref uncommon.lazyDefaultMemberName, defaultMemberName ?? "", null);
2629Interlocked.CompareExchange(ref uncommon.lazyComImportCoClassType, coClassType, ErrorTypeSymbol.UnknownResultType);
2770Interlocked.CompareExchange(
Symbols\MetadataOrSourceAssemblySymbol.cs (8)
90Interlocked.CompareExchange(ref _lazySpecialTypes,
94if ((object)Interlocked.CompareExchange(ref _lazySpecialTypes[(int)typeId], corType, null) != null)
141Interlocked.CompareExchange(ref _lazyNativeIntegerTypes, new NativeIntegerTypeSymbol[2], null);
153Interlocked.CompareExchange(ref _lazyNativeIntegerTypes[index], new NativeIntegerTypeSymbol(underlyingType), null);
201Interlocked.CompareExchange(ref _lazySpecialTypeMembers, specialTypeMembers, null);
213Interlocked.CompareExchange(ref _lazySpecialTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType);
273Interlocked.CompareExchange(ref _assembliesToWhichInternalAccessHasBeenAnalyzed, new ConcurrentDictionary<AssemblySymbol, IVTConclusion>(), null);
289Interlocked.CompareExchange(ref _lazyTypeConversions, new TypeConversions(this), null);
Symbols\Source\SourceMemberContainerSymbol.cs (5)
1313if (Interlocked.CompareExchange(ref _lazyTypeMembers, MakeTypeMembers(diagnostics), null) == null)
1608Interlocked.CompareExchange(ref _lazyEarlyAttributeDecodingMembersDictionary, membersByName, null);
1669var alreadyKnown = Interlocked.CompareExchange(ref _lazyMembersAndInitializers, membersAndInitializers, null);
1782if (Interlocked.CompareExchange(ref _lazyMembersDictionary, membersDictionary, null) == null)
3537var alreadyKnown = Interlocked.CompareExchange(ref _lazyDeclaredMembersAndInitializers, declaredMembersAndInitializers, DeclaredMembersAndInitializers.UninitializedSentinel);
Symbols\Source\SourceNamedTypeSymbol_Extension.cs (5)
79Interlocked.CompareExchange(ref _lazyExtensionInfo.LazyExtensionParameter, new ReceiverParameterSymbol(this, parameter), null);
101Interlocked.CompareExchange(ref _lazyExtensionInfo, new ExtensionInfo(), null);
112Interlocked.CompareExchange(ref _lazyExtensionInfo.LazyImplementationMap, builder.ToImmutable(), null);
130Interlocked.CompareExchange(ref _lazyExtensionInfo, new ExtensionInfo(), null);
135Interlocked.CompareExchange(ref _lazyExtensionInfo.LazyExtensionMarker, tryCreateExtensionMarker(), ErrorMethodSymbol.UnknownMethod);
Symbols\Source\SourcePropertySymbolBase.cs (5)
785Interlocked.CompareExchange(ref _lazyMergedBackingField, new StrongBox<SynthesizedBackingFieldSymbol?>(backingField), null);
798Interlocked.CompareExchange(ref _lazyDeclaredBackingField, CreateBackingField(), null);
806Interlocked.CompareExchange(ref _lazyMergedBackingField, new StrongBox<SynthesizedBackingFieldSymbol?>(backingField), null);
1217Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
1243Interlocked.CompareExchange(ref _lazySynthesizedSealedAccessor, MakeSynthesizedSealedAccessor(), null);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
Microsoft.CodeAnalysis.CSharp.Features (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Microsoft.CodeAnalysis.Debugging.Package (2)
Microsoft.CodeAnalysis.EditorFeatures (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.Utilities (3)
Microsoft.CodeAnalysis.Extensions.Package (5)
Microsoft.CodeAnalysis.Features (4)
Microsoft.CodeAnalysis.InteractiveHost (7)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (12)
Microsoft.CodeAnalysis.PooledObjects.Package (2)
Microsoft.CodeAnalysis.PublicApiAnalyzers (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Microsoft.CodeAnalysis.ResxSourceGenerator (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Scripting (2)
Microsoft.CodeAnalysis.Test.Utilities (4)
Microsoft.CodeAnalysis.Threading.Package (6)
Microsoft.CodeAnalysis.VisualBasic (69)
Symbols\Source\SourceModuleSymbol.vb (5)
187Interlocked.CompareExchange(_lazyGlobalNamespace, globalNS, Nothing)
262Interlocked.CompareExchange(_lazyQuickAttributeChecker, CreateQuickAttributeChecker(), Nothing)
353If Interlocked.CompareExchange(_lazyBoundImports, BindImports(cancellationToken), Nothing) Is Nothing Then
828Return Interlocked.CompareExchange(variable, value, comparand) Is comparand AndAlso comparand Is Nothing
834stored = Interlocked.CompareExchange(variable, value, comparand) Is comparand
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
Microsoft.CodeAnalysis.VisualBasic.Features (1)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (2)
Microsoft.CodeAnalysis.Workspaces (28)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (10)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (4)
Microsoft.Extensions.Caching.Hybrid (1)
Microsoft.Extensions.Caching.Memory (1)
Microsoft.Extensions.Caching.StackExchangeRedis (1)
Microsoft.Extensions.Diagnostics.Testing (1)
Microsoft.Extensions.ObjectPool (2)
Microsoft.Extensions.Primitives (1)
Microsoft.Extensions.ServiceDiscovery (2)
Microsoft.Extensions.Validation.ValidationsGenerator (1)
Microsoft.Maui.Controls (1)
Microsoft.ML.CodeAnalyzer.Tests (1)
Microsoft.ML.Core (6)
Microsoft.ML.Data (17)
Data\Combiner.cs (5)
28Interlocked.CompareExchange(ref _instance, new TextCombiner(), null) ??
54Interlocked.CompareExchange(ref _instance, new FloatAdder(), null) ??
76Interlocked.CompareExchange(ref _instance, new R4Adder(), null);
98Interlocked.CompareExchange(ref _instance, new R8Adder(), null) ??
121Interlocked.CompareExchange(ref _instance, new U4Adder(), null) ??
Microsoft.ML.DataView (16)
DataViewType.cs (16)
100Interlocked.CompareExchange(ref _instance, new TextDataViewType(), null) ??
141Interlocked.CompareExchange(ref _instSByte, new NumberDataViewType(typeof(sbyte)), null) ??
155Interlocked.CompareExchange(ref _instByte, new NumberDataViewType(typeof(byte)), null) ??
169Interlocked.CompareExchange(ref _instInt16, new NumberDataViewType(typeof(short)), null) ??
183Interlocked.CompareExchange(ref _instUInt16, new NumberDataViewType(typeof(ushort)), null) ??
197Interlocked.CompareExchange(ref _instInt32, new NumberDataViewType(typeof(int)), null) ??
211Interlocked.CompareExchange(ref _instUInt32, new NumberDataViewType(typeof(uint)), null) ??
225Interlocked.CompareExchange(ref _instInt64, new NumberDataViewType(typeof(long)), null) ??
239Interlocked.CompareExchange(ref _instUInt64, new NumberDataViewType(typeof(ulong)), null) ??
253Interlocked.CompareExchange(ref _instSingle, new NumberDataViewType(typeof(float)), null) ??
267Interlocked.CompareExchange(ref _instDouble, new NumberDataViewType(typeof(double)), null) ??
298Interlocked.CompareExchange(ref _instance, new RowIdDataViewType(), null) ??
337Interlocked.CompareExchange(ref _instance, new BooleanDataViewType(), null) ??
376Interlocked.CompareExchange(ref _instance, new DateTimeDataViewType(), null) ??
412Interlocked.CompareExchange(ref _instance, new DateTimeOffsetDataViewType(), null) ??
448Interlocked.CompareExchange(ref _instance, new TimeSpanDataViewType(), null) ??
Microsoft.ML.FastTree (2)
Microsoft.ML.Tests (2)
Microsoft.ML.Tokenizers (3)
Microsoft.ML.Transforms (5)
Microsoft.VisualBasic.Tests (1)
Microsoft.VisualStudio.LanguageServices.CSharp (2)
MSBuild (1)
MSBuildTaskHost (3)
PresentationCore (4)
PresentationFramework (12)
Roslyn.Diagnostics.Analyzers (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Roslyn.Diagnostics.VisualBasic.Analyzers (1)
System.Collections.Concurrent (5)
System.Collections.Immutable (19)
System\Collections\Immutable\ImmutableInterlocked.cs (15)
49T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue);
96T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue);
138T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray);
185T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray);
219return new ImmutableArray<T>(Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), value.array, comparand.array));
323ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
371ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
418ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
452ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
487ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
518ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
552ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
575ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
607ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
630ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
System.ComponentModel.Composition (1)
System.ComponentModel.TypeConverter (2)
System.Configuration.ConfigurationManager (1)
System.Console (1)
System.Data.Common (1)
System.Data.Odbc (2)
System.Diagnostics.DiagnosticSource (25)
System\Diagnostics\Activity.cs (13)
251Interlocked.CompareExchange(ref _id, id, null);
283Interlocked.CompareExchange(ref _parentId, parentId, null);
287Interlocked.CompareExchange(ref _parentId, Parent.Id, null);
322Interlocked.CompareExchange(ref _rootId, rootId, null);
490if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp), null) != null)
514if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp, set: true), null) != null)
529if (_events != null || Interlocked.CompareExchange(ref _events, new DiagLinkedList<ActivityEvent>(e), null) != null)
614if (_links != null || Interlocked.CompareExchange(ref _links, new DiagLinkedList<ActivityLink>(link), null) != null)
635if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp), null) != null)
659if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp, set: true), null) != null)
915Interlocked.CompareExchange(ref _spanId, spanId, null);
995Interlocked.CompareExchange(ref _parentSpanId, parentSpanId, null);
1136Interlocked.CompareExchange(ref _customProperties, new Dictionary<string, object>(), null);
System\Diagnostics\Metrics\AggregatorStore.cs (5)
250Interlocked.CompareExchange(ref NoLabelAggregator, aggregator, null);
266Interlocked.CompareExchange(ref Label1, new FixedSizeLabelNameDictionary<StringSequence1, ObjectSequence1, TAggregator>(), null);
273Interlocked.CompareExchange(ref Label2, new FixedSizeLabelNameDictionary<StringSequence2, ObjectSequence2, TAggregator>(), null);
280Interlocked.CompareExchange(ref Label3, new FixedSizeLabelNameDictionary<StringSequence3, ObjectSequence3, TAggregator>(), null);
287Interlocked.CompareExchange(ref LabelMany, new FixedSizeLabelNameDictionary<StringSequenceMany, ObjectSequenceMany, TAggregator>(), null);
System.Diagnostics.TraceSource (2)
System.IO.Pipes (1)
System.Linq.Expressions (4)
System.Net.Http (7)
System.Net.HttpListener (6)
System\Net\Managed\HttpEndPointListener.cs (6)
332} while (Interlocked.CompareExchange(ref _unhandledPrefixes, future, current) != current);
344} while (Interlocked.CompareExchange(ref _allPrefixes, future, current) != current);
358} while (Interlocked.CompareExchange(ref _prefixes, p2, prefs) != prefs);
373} while (Interlocked.CompareExchange(ref _unhandledPrefixes, future, current) != current);
387} while (Interlocked.CompareExchange(ref _allPrefixes, future, current) != current);
401} while (Interlocked.CompareExchange(ref _prefixes, p2, prefs) != prefs);
System.Net.Quic (3)
System.Net.Security (5)
System.Net.Sockets (11)
System.Net.WebClient (3)
System.Net.WebSockets.Client (3)
System.Private.CoreLib (83)
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureInfo.cs (9)
146Interlocked.CompareExchange(ref s_userDefaultCulture, GetUserDefaultCulture(), null);
152Interlocked.CompareExchange(ref s_userDefaultUICulture, GetUserDefaultUICulture(), null);
378Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null);
400Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null);
519Interlocked.CompareExchange<CultureInfo?>(ref _parent, culture, null);
715Interlocked.CompareExchange(ref _numInfo, temp, null);
741Interlocked.CompareExchange(ref _dateTimeInfo, temp, null);
1128cache = Interlocked.CompareExchange(ref s_cachedCulturesByName, cache, null) ?? cache;
1143cache = Interlocked.CompareExchange(ref s_cachedCulturesByLcid, cache, null) ?? cache;
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (7)
189Interlocked.CompareExchange(ref s_currentActiveTasks, new Dictionary<int, Task>(), null) ??
967if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1067if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1335Interlocked.CompareExchange(ref m_contingentProperties, new ContingentProperties(), null);
1485if (Interlocked.CompareExchange(ref contingentProps.m_completionEvent, newMre, null) != null)
1771if (Interlocked.CompareExchange(ref props.m_exceptionsHolder, holder, null) != null)
2166Interlocked.CompareExchange(ref props.m_exceptionalChildren, new List<Task>(), null);
src\System\RuntimeType.GenericCache.cs (6)
106if (Interlocked.CompareExchange(ref genericCache, newEntry, existing) == existing)
119if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing)
124if (Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, existingEntry) == existingEntry)
142if (Interlocked.CompareExchange(ref genericCache, newEntry, null) == null)
155if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing)
161TCache? currentEntry = Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, null);
System.Private.Uri (3)
System.Private.Xml (6)
System.Private.Xml.Linq (4)
System.Reflection.Metadata (9)
System.Reflection.MetadataLoadContext (7)
System.Runtime.Caching (8)
System.Security.Cryptography (1)
System.ServiceModel.UnixDomainSocket (2)
System.Text.Encoding.CodePages (4)
System.Text.Json (5)
System.Text.RegularExpressions (8)
System.Text.RegularExpressions.Generator (1)
System.Threading (2)
System.Threading.Channels (3)
System.Threading.RateLimiting (1)
System.Threading.Tasks.Dataflow (7)
System.Threading.Tasks.Parallel (3)
System.Transactions.Local (1)
System.Xaml (17)
System\Xaml\XamlSchemaContext.cs (10)
374Interlocked.CompareExchange(ref _xmlNsCompatDict, CreateDictionary<string, string>(), null);
503Interlocked.CompareExchange(ref _masterBracketCharacterCache, CreateDictionary<XamlType, Dictionary<string, SpecialBracketCharacters>>(), null);
514Interlocked.CompareExchange(ref _masterTypeList, CreateDictionary<Type, XamlType>(ReferenceEqualityComparer.Instance), null);
525Interlocked.CompareExchange(ref _masterValueConverterList, CreateDictionary<ReferenceEqualityTuple<Type, XamlType, Type>, object>(), null);
536Interlocked.CompareExchange(ref _masterMemberList, CreateDictionary<ReferenceEqualityTuple<MemberInfo, MemberInfo>, XamlMember>(), null);
731Interlocked.CompareExchange(ref _xmlnsInfo, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null);
742Interlocked.CompareExchange(ref _xmlnsInfoForDynamicAssemblies, CreateDictionary<WeakRefKey, XmlNsInfo>(), null);
754Interlocked.CompareExchange(ref _namespaceByUriList, CreateDictionary<string, XamlNamespace>(), null);
769Interlocked.CompareExchange(ref _xmlnsInfoForUnreferencedAssemblies, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null);
1270Interlocked.CompareExchange(ref _referenceAssemblyNames, asmNames, null);
Test.Utilities (11)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Text.Analyzers (12)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>