179 references to CompareExchange
dotnet-svcutil-lib (12)
FrameworkFork\System.ServiceModel\Internals\System\Runtime\SignalGate.cs (2)
43lastState = Interlocked.CompareExchange(ref _state, GateState.SignalPending, GateState.Locked); 67lastState = Interlocked.CompareExchange(ref _state, GateState.Unlocked, GateState.Locked);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpChannelFactory.cs (1)
1218if (Interlocked.CompareExchange(ref _httpRequestCompleted, 1, 0) == 0)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WebSocketTransportDuplexSessionChannel.cs (7)
330if (Interlocked.CompareExchange(ref _cleanupStatus, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 510if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Cancelled, AsyncReceiveState.Started) == AsyncReceiveState.Started) 725int currentState = Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Started, AsyncReceiveState.Finished); 806if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Finished, AsyncReceiveState.Started) == AsyncReceiveState.Started) 1181if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 1259if (Interlocked.CompareExchange(ref _messageSourceCleanState, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 1301if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\BufferedReceiveBinder.cs (2)
75if (Interlocked.CompareExchange(ref _pendingOperationSemaphore, 1, 0) == 0) 97if (Interlocked.CompareExchange(ref _pendingOperationSemaphore, 1, 0) == 0)
Microsoft.AspNetCore.Server.Kestrel.Core (2)
Internal\Http2\Http2Connection.cs (1)
279if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None)
Internal\Http3\Http3Connection.cs (1)
122if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None)
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (1)
src\Servers\Kestrel\Transport.Sockets\src\Internal\IOQueue.cs (1)
23if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (1)
Internal\IOQueue.cs (1)
23if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0)
Microsoft.AspNetCore.SignalR.Core (1)
Internal\HubCallerClients.cs (1)
96return Interlocked.CompareExchange(ref _shouldReleaseSemaphore, 0, 1) == 1;
Microsoft.Build (3)
BackEnd\Components\RequestBuilder\RequestBuilder.cs (1)
1465var prev = Interlocked.CompareExchange(ref _availableThreads, count - 1, count);
BackEnd\Components\Scheduler\Scheduler.cs (1)
1391var loggedWarnings = Interlocked.CompareExchange(ref _loggedWarningsForProxyBuildsOnOutOfProcNodes, 1, 0);
Evaluation\Context\EvaluationContext.cs (1)
120if (Interlocked.CompareExchange(ref _used, 1, 0) == 0)
Microsoft.CodeAnalysis (7)
Collections\SmallConcurrentSetOfInts.cs (1)
132val = Interlocked.CompareExchange(ref slot, i, unoccupied);
Emit\NoPia\CommonEmbeddedEvent.cs (1)
84Interlocked.CompareExchange(ref _isUsedForComAwareEventBinding, 1, 0) == 0))
InternalUtilities\InterlockedOperations.cs (1)
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
InternalUtilities\ThreadSafeFlagOperations.cs (2)
23while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState); 39while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState);
MetadataReader\PEModule.cs (1)
2676while (Interlocked.CompareExchange(
Microsoft.CodeAnalysis.CodeStyle (2)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (1)
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
Microsoft.CodeAnalysis.CSharp (9)
Symbols\Metadata\PE\PEEventSymbol.cs (1)
268Interlocked.CompareExchange(ref _lazyDeclaredAccessibility, (int)accessibility, UnsetAccessibility);
Symbols\Metadata\PE\PEMethodSymbol.cs (1)
1712Interlocked.CompareExchange(ref AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0);
Symbols\Metadata\PE\PEPropertySymbol.cs (2)
537Interlocked.CompareExchange(ref _declaredAccessibility, (int)accessibility, UnsetAccessibility); 1054Interlocked.CompareExchange(ref AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0);
Symbols\MissingMetadataTypeSymbol.cs (1)
301Interlocked.CompareExchange(ref _lazyTypeId, (int)typeId, -1);
Symbols\Source\SourceFixedFieldSymbol.cs (1)
127if (Interlocked.CompareExchange(ref _fixedSize, size, FixedSizeNotInitialized) == FixedSizeNotInitialized)
Symbols\Source\SourceMemberContainerSymbol.cs (2)
2348Interlocked.CompareExchange(ref _lazyKnownCircularStruct, (int)ThreeState.False, (int)ThreeState.Unknown); 2355if (Interlocked.CompareExchange(ref _lazyKnownCircularStruct, value, (int)ThreeState.Unknown) == (int)ThreeState.Unknown)
Symbols\TypeWithAnnotations.cs (1)
983Interlocked.CompareExchange(ref _resolved, value: (int)getResolvedAnnotationCore(), comparand: Unresolved);
Microsoft.CodeAnalysis.LanguageServer (1)
HostWorkspace\LanguageServerProjectSystem.cs (1)
149var shouldShowToast = Interlocked.CompareExchange(ref _displayedToast, value: 1, comparand: 0) == 0;
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Services\BrokeredServiceBase.FactoryBase.cs (1)
66if (Interlocked.CompareExchange(ref s_cultureInitialized, 1, 0) == 0)
Microsoft.CodeAnalysis.Scripting (1)
ScriptExecutionState.cs (1)
43var wasAlreadyFrozen = Interlocked.CompareExchange(ref _frozen, 1, 0) == 1;
Microsoft.CodeAnalysis.VisualBasic (8)
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.SymbolsCollection.vb (1)
165Interlocked.CompareExchange(_sealed, 1, 0)
Symbols\MergedNamespaceSymbol.vb (1)
270Interlocked.CompareExchange(_lazyEmbeddedKind, value, EmbeddedSymbolKind.Unset)
Symbols\Metadata\PE\PEEventSymbol.vb (1)
169Interlocked.CompareExchange(Me._lazyDeclaredAccessibility, DirectCast(accessibility, Integer), s_unsetAccessibility)
Symbols\Metadata\PE\PEMethodSymbol.vb (1)
845Interlocked.CompareExchange(AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0)
Symbols\Metadata\PE\PEPropertySymbol.vb (1)
182Interlocked.CompareExchange(Me._lazyDeclaredAccessibility, GetDeclaredAccessibility(Me), s_unsetAccessibility)
Symbols\Source\SourceModuleSymbol.vb (2)
861Interlocked.CompareExchange(variable, value, comparand) 866If Interlocked.CompareExchange(variable, value, comparand) <> comparand AndAlso
Symbols\Source\SourceNamespaceSymbol.vb (1)
94Interlocked.CompareExchange(_lazyEmbeddedKind, value, EmbeddedSymbolKind.Unset)
Microsoft.CodeAnalysis.Workspaces (4)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (1)
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
Workspace\ProjectSystem\ProjectSystemProject.cs (2)
536if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0) 544if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
Microsoft.CodeAnalysis.Workspaces.MSBuild (1)
MSBuild\BuildHostProcessManager.cs (1)
424if (Interlocked.CompareExchange(ref _disposed, value: 1, comparand: 0) != 0)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (4)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (1)
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
src\Compilers\Core\Portable\InternalUtilities\ThreadSafeFlagOperations.cs (2)
23while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState); 39while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState);
Microsoft.DotNet.RemoteExecutor (1)
RemoteInvokeHandle.cs (1)
180Interlocked.CompareExchange(ref s_clrMdLock, 1, 0) == 0) // Make sure we only attach to one process at a time.
Microsoft.Extensions.Caching.Hybrid (1)
Internal\DefaultHybridCache.CacheItem.cs (1)
72var updated = Interlocked.CompareExchange(ref _refCount, oldValue + 1, oldValue);
Microsoft.Extensions.Caching.Memory (1)
MemoryCache.cs (1)
488if (Interlocked.CompareExchange(ref lockFlag, 1, 0) == 0)
Microsoft.Extensions.Http.Diagnostics (1)
Latency\Internal\HttpRequestLatencyListener.cs (1)
43if (Interlocked.CompareExchange(ref _enabled, 1, 0) == 0)
Microsoft.Extensions.Telemetry (1)
Latency\Internal\CheckpointTracker.cs (1)
66if (token.Position > -1 && Interlocked.CompareExchange(ref _checkpointAdded[token.Position], 1, 0) == 0)
Microsoft.Extensions.TimeProvider.Testing (1)
FakeTimeProvider.cs (1)
236if (Interlocked.CompareExchange(ref _wakeWaitersGate, 1, 0) == 1)
Microsoft.ML.AutoML.Interactive (1)
ActionThrottler.cs (1)
36if (Interlocked.CompareExchange(ref _updatePending, 1, 0) == 0) // _updatePending is int initialized with 0
Microsoft.ML.Data (1)
DataLoadSave\Text\TextLoaderParser.cs (1)
1493Interlocked.CompareExchange(ref _csrc, csrc, 0);
Microsoft.NET.StringTools (1)
WeakStringCache.Concurrent.cs (1)
73if (Interlocked.CompareExchange(ref _scavengeThreshold, int.MaxValue, scavengeThreshold) == scavengeThreshold)
Microsoft.VisualStudio.LanguageServices (2)
EditAndContinue\EditAndContinueFeedbackDiagnosticFileProvider.cs (1)
112if (Interlocked.CompareExchange(ref _isLogCollectionInProgress, 1, 0) == 0)
Workspace\VisualStudioSourceGeneratorTelemetryCollectorWorkspaceServiceFactory.cs (1)
72if (Interlocked.CompareExchange(ref _subscribedToSolutionEvents, 1, 0) == 0)
MSBuildTaskHost (3)
Concurrent\ConcurrentQueue.cs (3)
353if (Interlocked.CompareExchange(ref _headAndTail.Tail, tail + FreezeOffset, tail) == tail) 388if (Interlocked.CompareExchange(ref _headAndTail.Head, currentHead + 1, currentHead) == currentHead) 519if (Interlocked.CompareExchange(ref _headAndTail.Tail, currentTail + 1, currentTail) == currentTail)
PresentationCore (1)
System\Windows\Media\MediaSystem.cs (1)
152if (System.Threading.Interlocked.CompareExchange(ref s_DisableDirtyRectangles, disableDirtyRectangles, oldValue) == oldValue)
PresentationFramework (6)
MS\Internal\PtsHost\FlowDocumentPage.cs (1)
801if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PageBreakRecord.cs (1)
134if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsCache.cs (2)
166if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0)) 293if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0))
MS\Internal\PtsHost\PtsContext.cs (1)
75if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsPage.cs (1)
708if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
System.Collections.Concurrent (2)
System\Collections\Concurrent\BlockingCollection.cs (2)
456if (Interlocked.CompareExchange(ref _currentAdders, observedAdders + 1, observedAdders) == observedAdders) 1456if (Interlocked.CompareExchange(ref _currentAdders, observedAdders | COMPLETE_ADDING_ON_MASK, observedAdders) == observedAdders)
System.ComponentModel.Composition (10)
Microsoft\Internal\Lock.Reader.cs (1)
23if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
Microsoft\Internal\Lock.ReaderWriter.cs (1)
35if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
Microsoft\Internal\Lock.Writer.cs (1)
23if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\Hosting\AggregateCatalog.cs (1)
182if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\Hosting\AggregateExportProvider.cs (1)
104if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\Hosting\AssemblyCatalog.cs (1)
513if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\Hosting\CompositionLock.cs (2)
47if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0) 132if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\Hosting\CompositionScopeDefinition.cs (1)
89if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\ComponentModel\Composition\ReflectionModel\DisposableReflectionComposablePart.cs (1)
36if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System.ComponentModel.Composition.Registration (3)
System\Threading\ReadLock.cs (1)
20if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\Threading\ReadWriteLock.cs (1)
33if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System\Threading\WriteLock.cs (1)
20if (Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
System.Configuration.ConfigurationManager (1)
System\Configuration\SafeBitVector32.cs (1)
34int result = Interlocked.CompareExchange(ref _data, newData, oldData);
System.Console (1)
System\ConsolePal.Unix.cs (1)
1090bool invalidateSettings = Interlocked.CompareExchange(ref s_invalidateCachedSettings, 0, 1) == 1;
System.Data.Odbc (1)
Common\System\Data\ProviderBase\DbConnectionPool.cs (1)
595started = Interlocked.CompareExchange(ref _pendingOpensWaiting, 1, 0) == 0;
System.Net.Http (1)
System\Net\Http\HttpRequestMessage.cs (1)
171internal bool MarkAsSent() => Interlocked.CompareExchange(ref _sendStatus, MessageAlreadySent, MessageNotYetSent) == MessageNotYetSent;
System.Net.HttpListener (3)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (3)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0);
System.Net.Mail (3)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (3)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0);
System.Net.Quic (6)
System\Net\Quic\Internal\MsQuicSafeHandle.cs (2)
170} while (Interlocked.CompareExchange(ref _rentCount, oldCount + 1, oldCount) != oldCount); 177return Interlocked.CompareExchange(ref _rentCount, -1, 0) == 0;
System\Net\Quic\QuicStream.cs (4)
332if (totalCopied > 0 && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) 408if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 496if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 576return (_receiveBuffers.HasCapacity() && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) ? QUIC_STATUS_CONTINUE : QUIC_STATUS_SUCCESS;
System.Net.Requests (7)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (3)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0);
System\Net\TimerThread.cs (4)
464TimerThreadState oldState = (TimerThreadState)Interlocked.CompareExchange( 489if (Interlocked.CompareExchange(ref s_threadState, (int)TimerThreadState.Running, (int)TimerThreadState.Running) != 570Interlocked.CompareExchange(ref s_threadState, (int)TimerThreadState.Idle, (int)TimerThreadState.Running); 574if (Interlocked.CompareExchange(ref s_threadState, (int)TimerThreadState.Running, (int)TimerThreadState.Idle) ==
System.Net.Security (2)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (2)
108} while (Interlocked.CompareExchange(ref _rentCount, oldCount + 1, oldCount) != oldCount); 115return Interlocked.CompareExchange(ref _rentCount, -1, 0) == 0;
System.Private.CoreLib (25)
src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueueSegment.cs (2)
135if (Interlocked.CompareExchange(ref _headAndTail.Head, currentHead + 1, currentHead) == currentHead) 293if (Interlocked.CompareExchange(ref _headAndTail.Tail, currentTail + 1, currentTail) == currentTail)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\NameInfo.cs (1)
27if (Interlocked.CompareExchange(ref lastIdentity, newIdentity, snapshot) == snapshot)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (2)
180} while (Interlocked.CompareExchange(ref _state, newState, oldState) != oldState); 255} while (Interlocked.CompareExchange(ref _state, newState, oldState) != oldState);
src\libraries\System.Private.CoreLib\src\System\Threading\DeferredDisposableLifetime.cs (4)
58if (Interlocked.CompareExchange(ref _count, newCount, oldCount) == oldCount) 72if (Interlocked.CompareExchange(ref _count, newCount, oldCount) == oldCount) 85if (Interlocked.CompareExchange(ref _count, newCount, oldCount) == oldCount) 104if (Interlocked.CompareExchange(ref _count, newCount, oldCount) == oldCount)
src\libraries\System.Private.CoreLib\src\System\Threading\Interlocked.cs (2)
593int oldValue = CompareExchange(ref location1, newValue, current); 659int oldValue = CompareExchange(ref location1, newValue, current);
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelLock.cs (3)
118int state = Interlocked.CompareExchange(ref _state, LockedMask, 0); 135return (state & LockedMask) == 0 && Interlocked.CompareExchange(ref _state, state + LockedMask, state) == state; 176Interlocked.CompareExchange(ref _state, state + (LockedMask - WaiterCountIncrement), state) == state)
src\libraries\System.Private.CoreLib\src\System\Threading\ManualResetEventSlim.cs (1)
688if (Interlocked.CompareExchange(ref m_combinedState, newState, oldState) == oldState)
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.WorkerThread.cs (2)
110Interlocked.CompareExchange(ref threadPoolInstance._numThreadsBeingKeptAlive, count + 1, count); 365int prevCount = Interlocked.CompareExchange(ref threadPoolInstance._separated.numRequestedWorkers, count - 1, count);
src\libraries\System.Private.CoreLib\src\System\Threading\SpinLock.cs (2)
97int result = Interlocked.CompareExchange(ref location, value, comparand); 395if (Interlocked.CompareExchange(ref _owner, observedOwner - 2, observedOwner) == observedOwner)
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (4)
696(Interlocked.CompareExchange(ref m_stateFlags, oldFlags | newBits, oldFlags) == oldFlags || 706int oldFlags = Interlocked.CompareExchange(ref m_stateFlags, flags | newBits, flags); 721oldFlags = Interlocked.CompareExchange(ref m_stateFlags, flags | newBits, flags); 1198Interlocked.CompareExchange(ref m_taskId, newId, 0);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskScheduler.cs (1)
368Interlocked.CompareExchange(ref m_taskSchedulerId, newId, 0);
src\System\Threading\Interlocked.CoreCLR.cs (1)
119return CompareExchange(ref location1, value, comparand); // Must expand intrinsic
System.Private.Xml.Linq (4)
System\Xml\Linq\XHashtable.cs (4)
179entryIdx = Interlocked.CompareExchange(ref _buckets[bucketIdx], FullList, EndOfList); 192entryIdx = Interlocked.CompareExchange(ref _entries[entryIdx].Next, FullList, EndOfList); 304entryIndex = Interlocked.CompareExchange(ref _buckets[hashCode & (_buckets.Length - 1)], newEntry, EndOfList); 306entryIndex = Interlocked.CompareExchange(ref _entries[entryIndex].Next, newEntry, EndOfList);
System.Runtime.Caching (3)
System\Runtime\Caching\MemoryCacheEntry.cs (1)
205return (Interlocked.CompareExchange(ref _state, (int)value, (int)comparand) == (int)comparand);
System\Runtime\Caching\SafeBitVector32.cs (2)
39int result = Interlocked.CompareExchange(ref _data, newData, oldData); 68int result = Interlocked.CompareExchange(ref _data, newData, oldData);
System.Security.Cryptography (1)
src\libraries\Common\src\System\Security\Cryptography\SP800108HmacCounterKdfImplementationManaged.cs (1)
84if (Interlocked.CompareExchange(ref _keyReferenceCount, incrementedCount, current) == current)
System.Text.Json (2)
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.WriteHelpers.cs (1)
378Interlocked.CompareExchange(ref _canUseSerializeHandlerInStreamingState, 1, 0);
System\Text\Json\Serialization\Metadata\ReflectionEmitCachingMemberAccessor.Cache.cs (1)
44if (Interlocked.CompareExchange(ref _evictLock, 1, 0) == 0)
System.Text.RegularExpressions.Generator (1)
Stubs.cs (1)
92uint oldValue = (uint)Interlocked.CompareExchange(ref Unsafe.As<uint, int>(ref location1), (int)newValue, (int)current);
System.Threading (15)
System\Threading\Barrier.cs (1)
270return Interlocked.CompareExchange(ref _currentTotalCount, newCurrentTotal, currentTotal) == currentTotal;
System\Threading\CountdownEvent.cs (2)
233if (Interlocked.CompareExchange(ref _currentCount, observedCount - signalCount, observedCount) == observedCount) 340if (Interlocked.CompareExchange(ref _currentCount, observedCount + signalCount, observedCount) == observedCount)
System\Threading\ReaderWriterLock.cs (12)
85if (Interlocked.CompareExchange(ref _state, LockStates.Reader, 0) == 0) 132currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState); 186currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingReader, knownState); 287if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0) 313currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Writer, knownState); 356currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingWriter, knownState); 533currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState); 641currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState); 702int knownState = Interlocked.CompareExchange(ref _state, LockStates.Writer, LockStates.Reader); 811currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState); 941if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0) 958Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState) == knownState)
System.Threading.Channels (1)
System\Threading\Channels\AsyncOperation.cs (1)
378Interlocked.CompareExchange(ref _completionReserved, 1, 0) == 0;
System.Threading.RateLimiting (2)
System\Threading\RateLimiting\TranslatingLimiter.cs (2)
46if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0) 57if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
System.Threading.Tasks.Dataflow (4)
Base\DataflowBlock.cs (4)
574Interlocked.CompareExchange(ref source._cancellationState, CANCELLATION_STATE_COMPLETING, CANCELLATION_STATE_REGISTERED) == CANCELLATION_STATE_REGISTERED) 673Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_COMPLETING, curState) == curState)) 700Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_RESERVED, CANCELLATION_STATE_REGISTERED) == CANCELLATION_STATE_REGISTERED); 722if (Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_REGISTERED, CANCELLATION_STATE_RESERVED) != CANCELLATION_STATE_RESERVED)
System.Threading.Tasks.Parallel (1)
System\Threading\Tasks\ParallelLoopState.cs (1)
318if (Interlocked.CompareExchange(ref _loopStateFlags, oldState | newState, oldState) == oldState)
System.Xaml (1)
System\Xaml\Schema\Reflector.cs (1)
372updated = oldValue == Interlocked.CompareExchange(ref flags, newValue, oldValue);