1260 references to Interlocked
BasicWebSite (2)
ActionDescriptorCreationCounter.cs (2)
16var callCount = Interlocked.Read(ref _callCount); 41Interlocked.Increment(ref _callCount);
ClientSample (2)
Tcp\SocketAwaitable.cs (2)
51ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted)) 66var continuation = Interlocked.Exchange(ref _callback, _callbackCompleted);
HttpStress (3)
Program.cs (3)
534Interlocked.Increment(ref counter); 535Interlocked.Increment(ref total); 599Interlocked.Increment(ref reuseAddressFailure);
ILCompiler.DependencyAnalysisFramework (3)
EventSourceLogStrategy.cs (3)
77nodeIndex = Interlocked.Increment(ref ObjectIndex); 86GraphId = Interlocked.Increment(ref s_GraphIds); 88RootIndex = Interlocked.Increment(ref ObjectIndex);
InMemory.FunctionalTests (3)
ConnectionLimitTests.cs (2)
168if (e && Interlocked.Increment(ref opened) >= count) 176if (Interlocked.Increment(ref closed) >= count)
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
InProcessWebSite (4)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (4)
151Interlocked.Increment(ref _waitingRequestCount); 159Interlocked.Decrement(ref _waitingRequestCount); 585Interlocked.Increment(ref _requestsInFlight); 592Interlocked.Decrement(ref _requestsInFlight);
Interop.FunctionalTests (5)
Http3\Http3RequestTests.cs (1)
767Interlocked.Increment(ref requestCount);
HttpClientHttp2InteropTests.cs (4)
114if (Interlocked.Increment(ref requestsReceived) == requestCount) 162if (Interlocked.Increment(ref requestsReceived) == requestCount) 1206var count = Interlocked.Increment(ref requestCount); 1267var count = Interlocked.Increment(ref requestCount);
Microsoft.AspNetCore.App.Analyzers (1)
src\Shared\RoslynUtils\WellKnownTypes.cs (1)
82Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null);
Microsoft.AspNetCore.Components (1)
ElementReference.cs (1)
61var id = Interlocked.Increment(ref _nextIdForWebAssemblyOnly);
Microsoft.AspNetCore.Components.Endpoints (1)
DependencyInjection\HotReloadService.cs (1)
39var current = Interlocked.Exchange(ref _tokenSource, new CancellationTokenSource());
Microsoft.AspNetCore.Components.Server (1)
Circuits\RemoteRenderer.cs (1)
157var renderId = Interlocked.Increment(ref _nextRenderId);
Microsoft.AspNetCore.Components.Tests (2)
NavigationManagerTest.cs (2)
313Interlocked.Increment(ref completedHandlerCount); 635Interlocked.Increment(ref completedHandlerCount);
Microsoft.AspNetCore.Components.WebAssembly (2)
Hosting\WebAssemblyHostConfiguration.cs (1)
132var previousToken = Interlocked.Exchange(ref _changeToken, new ConfigurationReloadToken());
HotReload\WebAssemblyHotReload.cs (1)
50Interlocked.CompareExchange(ref _hotReloadAgent, new HotReloadAgent(m => Debug.WriteLine(m)), null);
Microsoft.AspNetCore.ConcurrencyLimiter (3)
ConcurrencyLimiterEventSource.cs (3)
38Interlocked.Increment(ref _rejectedRequests); 54Interlocked.Increment(ref _queueLength); 77Interlocked.Decrement(ref _parent._queueLength);
Microsoft.AspNetCore.ConcurrencyLimiter.Microbenchmarks (2)
QueueFullOverhead.cs (1)
47if (Interlocked.Increment(ref _requestCount) == _numRequests)
QueueRequestsOverwritten.cs (1)
47if (Interlocked.Increment(ref _rejectionCount) == _numRejects)
Microsoft.AspNetCore.ConcurrencyLimiter.Tests (2)
TestUtils.cs (2)
91Interlocked.Increment(ref _queuedRequests); 93Interlocked.Decrement(ref _queuedRequests);
Microsoft.AspNetCore.Cryptography.Internal (2)
UnsafeNativeMethods.cs (1)
445if (Interlocked.CompareExchange(ref safeLibraryHandle, newHandle, null) is not null)
WeakReferenceHelpers.cs (1)
44WeakReference<T>? currentWeakRef = Interlocked.CompareExchange(ref weakReference, newWeakRef, existingWeakRef);
Microsoft.AspNetCore.DataProtection (2)
KeyManagement\XmlKeyManager.cs (2)
263return Interlocked.CompareExchange<CancellationTokenSource?>(ref _cacheExpirationTokenSource, null, null).Token; 395Interlocked.Exchange(ref _cacheExpirationTokenSource, new CancellationTokenSource())?.Cancel();
Microsoft.AspNetCore.DataProtection.Extensions (1)
TimeLimitedDataProtector.cs (1)
43retVal = Interlocked.CompareExchange(ref _innerProtectorWithTimeLimitedPurpose, newValue, null) ?? newValue;
Microsoft.AspNetCore.Hosting (4)
Internal\HostingEventSource.cs (4)
55Interlocked.Increment(ref _totalRequests); 56Interlocked.Increment(ref _currentRequests); 64Interlocked.Decrement(ref _currentRequests); 84Interlocked.Increment(ref _failedRequests);
Microsoft.AspNetCore.Http (4)
Features\HttpRequestIdentifierFeature.cs (1)
28_id = GenerateRequestId(Interlocked.Increment(ref _requestId));
src\Shared\CancellationTokenSourcePool.cs (3)
19Interlocked.Decrement(ref _count); 27if (Interlocked.Increment(ref _count) > MaxQueueSize || !cts.TryReset()) 29Interlocked.Decrement(ref _count);
Microsoft.AspNetCore.Http.Connections (5)
Internal\HttpConnectionsEventSource.cs (5)
40Interlocked.Increment(ref _connectionsStopped); 41Interlocked.Decrement(ref _currentConnections); 58Interlocked.Increment(ref _connectionsStarted); 59Interlocked.Increment(ref _currentConnections); 73Interlocked.Increment(ref _connectionsTimedOut);
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
src\Shared\RoslynUtils\WellKnownTypes.cs (1)
82Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null);
Microsoft.AspNetCore.Mvc (1)
HotReloadService.cs (1)
78var current = Interlocked.Exchange(ref _tokenSource, new CancellationTokenSource());
Microsoft.AspNetCore.Mvc.Core (2)
Infrastructure\OrderedEndpointsSequenceProvider.cs (1)
18return Interlocked.Increment(ref _current);
Routing\ControllerActionEndpointDataSourceIdProvider.cs (1)
12return Interlocked.Increment(ref _nextId);
Microsoft.AspNetCore.Mvc.RazorPages (1)
Infrastructure\PageActionEndpointDataSourceIdProvider.cs (1)
12return Interlocked.Increment(ref _nextId);
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (2)
RedisOutputCacheStore.cs (2)
363ReleaseConnection(Interlocked.Exchange(ref _cache, null)); 409ReleaseConnection(Interlocked.CompareExchange(ref _cache, null, cache));
Microsoft.AspNetCore.ResponseCaching (1)
FastGuid.cs (1)
50return new FastGuid(Interlocked.Increment(ref NextId));
Microsoft.AspNetCore.Routing (1)
EndpointRoutingMiddleware.cs (1)
254var initializationTask = Interlocked.CompareExchange(ref _initializationTask, initialization.Task, null);
Microsoft.AspNetCore.Routing.Tests (2)
Builder\RoutingEndpointConventionBuilderExtensionsTest.cs (2)
312var conventions = Interlocked.Exchange(ref _conventions, null); 322var finallyConventions = Interlocked.Exchange(ref _finallyConventions, null);
Microsoft.AspNetCore.Server.HttpSys (10)
AsyncAcceptContext.cs (3)
131var value = Interlocked.Exchange(ref _expectedCompletionCount, 1); // should have been 0 143var value = Interlocked.Decrement(ref _expectedCompletionCount); // should have been 1, so now 0 155var value = Interlocked.Decrement(ref _expectedCompletionCount); // should have been 1, so now 0
MessagePump.cs (4)
143return Interlocked.Increment(ref _outstandingRequests); 148return Interlocked.Decrement(ref _outstandingRequests); 178if (Interlocked.Exchange(ref _shutdownSignalCompleted, 1) == 0) 186if (Interlocked.Exchange(ref _stopping, 1) == 1)
NativeInterop\HttpServerSessionHandle.cs (1)
34if (Interlocked.Increment(ref disposed) == 1)
NativeInterop\SafeNativeOverlapped.cs (1)
38IntPtr oldHandle = Interlocked.Exchange(ref handle, IntPtr.Zero);
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
38Interlocked.CompareExchange(ref _extra, newDict, null);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (1)
ServerTests.cs (1)
254if (Interlocked.Increment(ref requestCount) == requestLimit)
Microsoft.AspNetCore.Server.IIS (6)
Core\IO\AsyncIOEngine.cs (3)
222Interlocked.Exchange(ref _cachedAsyncReadOperation, null) ?? 226Interlocked.Exchange(ref _cachedAsyncWriteOperation, null) ?? 230Interlocked.Exchange(ref _cachedAsyncFlushOperation, null) ??
Core\IO\AsyncIOOperation.cs (2)
40var previousContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null); 114var continuation = Interlocked.CompareExchange(ref _continuation, CallbackCompleted, null);
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
38Interlocked.CompareExchange(ref _extra, newDict, null);
Microsoft.AspNetCore.Server.Kestrel.Core (51)
Internal\CertificatePathWatcher.cs (1)
203var previousToken = Interlocked.Exchange(ref _reloadToken, new());
Internal\Http\Http1ContentLengthMessageBody.cs (5)
39return new ReadResult(_readResult.Buffer, Interlocked.Exchange(ref _userCanceled, 0) == 1, isCompleted: true); 98if (!_readResult.IsCanceled || Interlocked.Exchange(ref _userCanceled, 0) == 1 || _cannotResetInputPipe) 126readResult = new ReadResult(_readResult.Buffer, Interlocked.Exchange(ref _userCanceled, 0) == 1, isCompleted: true); 146if (!_readResult.IsCanceled || Interlocked.Exchange(ref _userCanceled, 0) == 1 || _cannotResetInputPipe) 256Interlocked.Exchange(ref _userCanceled, 1);
Internal\Http\Http1UpgradeMessageBody.cs (4)
45Interlocked.Exchange(ref _userCanceled, 1); 68} while (readResult.IsCanceled && Interlocked.Exchange(ref _userCanceled, 0) == 0); 88} while (readResult.IsCanceled && Interlocked.Exchange(ref _userCanceled, 0) == 0); 99while (readResult.IsCanceled && Interlocked.Exchange(ref _userCanceled, 0) == 0)
Internal\Http2\Http2Connection.cs (6)
243if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None) 1229if (IsEnhanceYourCalmLimitEnabled && Interlocked.Increment(ref _enhanceYourCalmCount) > EnhanceYourCalmTickWindowCount * EnhanceYourCalmMaximumCount) 1318Interlocked.Exchange(ref _enhanceYourCalmCount, 0); 1731if (Interlocked.Exchange(ref _isClosed, 1) == 0) 1742Interlocked.Increment(ref _clientActiveStreamCount); 1747Interlocked.Decrement(ref _clientActiveStreamCount);
Internal\Http3\Http3Connection.cs (3)
92private long GetCurrentGoAwayStreamId() => Interlocked.Read(ref _highestOpenedRequestStreamId) + 4; 119if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None) 144if (Interlocked.Exchange(ref _stoppedAcceptingStreams, 1) == 0)
Internal\Http3\Http3ControlStream.cs (1)
110if (Interlocked.Exchange(ref _isClosed, 1) == 0)
Internal\Http3\Http3Stream.cs (1)
570if (Interlocked.Exchange(ref _isClosed, 1) == 0)
Internal\Infrastructure\ConnectionManager.cs (1)
29public long GetNewConnectionId() => Interlocked.Increment(ref _lastConnectionId);
Internal\Infrastructure\KestrelEventSource.cs (13)
58Interlocked.Increment(ref _totalConnections); 59Interlocked.Increment(ref _currentConnections); 81Interlocked.Decrement(ref _currentConnections); 159Interlocked.Increment(ref _connectionQueueLength); 165Interlocked.Decrement(ref _connectionQueueLength); 171Interlocked.Increment(ref _currentTlsHandshakes); 172Interlocked.Increment(ref _totalTlsHandshakes); 190Interlocked.Decrement(ref _currentTlsHandshakes); 214Interlocked.Increment(ref _failedTlsHandshakes); 280Interlocked.Increment(ref _httpRequestQueueLength); 286Interlocked.Decrement(ref _httpRequestQueueLength); 292Interlocked.Increment(ref _currentUpgradedHttpRequests); 298Interlocked.Decrement(ref _currentUpgradedHttpRequests);
Internal\Infrastructure\ResourceCounter.cs (2)
47var prev = Interlocked.CompareExchange(ref _count, count + 1, count); 62Interlocked.Decrement(ref _count);
Internal\Infrastructure\StreamCloseAwaitable.cs (2)
30ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted)) 43Interlocked.Exchange(ref _callback, _callbackCompleted)?.Invoke();
Internal\Infrastructure\TimeoutControl.cs (8)
48Interlocked.Exchange(ref _lastTimestamp, _timeProvider.GetTimestamp()); 57Interlocked.Exchange(ref _lastTimestamp, timestamp); 64if (timestamp > Interlocked.Read(ref _timeoutTimestamp)) 80if (Interlocked.Read(ref _timeoutTimestamp) != long.MaxValue) 182Interlocked.Exchange(ref _timeoutTimestamp, long.MaxValue); 193Interlocked.Exchange(ref _timeoutTimestamp, Interlocked.Read(ref _lastTimestamp) + timeoutTicks + _heartbeatIntervalTicks); 290var currentTimeUpperBound = Interlocked.Read(ref _lastTimestamp) + _heartbeatIntervalTicks;
Internal\KestrelServerImpl.cs (1)
241if (Interlocked.Exchange(ref _stopping, 1) == 1)
src\Shared\CancellationTokenSourcePool.cs (3)
19Interlocked.Decrement(ref _count); 27if (Interlocked.Increment(ref _count) > MaxQueueSize || !cts.TryReset()) 29Interlocked.Decrement(ref _count);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (1)
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (4)
SchedulerBenchmark.cs (1)
92var result = Interlocked.Decrement(ref _counters[counter].Remaining);
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
src\Servers\Kestrel\Transport.Sockets\src\Internal\IOQueue.cs (2)
21if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0) 55if (Interlocked.Exchange(ref _doingWork, 1) == 1)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (2)
Internal\NamedPipeConnectionListener.cs (1)
167if (Interlocked.Exchange(ref _disposed, 1) == 0)
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (1)
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (9)
Internal\IOQueue.cs (2)
21if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0) 55if (Interlocked.Exchange(ref _doingWork, 1) == 1)
Internal\SocketAwaitableEventArgs.cs (2)
37if (c != null || (c = Interlocked.CompareExchange(ref _continuation, _continuationCompleted, null)) != null) 74var prevContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null);
Internal\SocketSenderPool.cs (3)
29Interlocked.Decrement(ref _count); 38if (_disposed || Interlocked.Increment(ref _count) > MaxQueueSize) 40Interlocked.Decrement(ref _count);
SocketConnectionContextFactory.cs (1)
90var setting = _settings[Interlocked.Increment(ref _settingsIndex) % _settingsCount];
src\Servers\Kestrel\shared\CorrelationIdGenerator.cs (1)
16public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
Microsoft.AspNetCore.Shared.Tests (1)
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
38Interlocked.CompareExchange(ref _extra, newDict, null);
Microsoft.AspNetCore.SignalR.Client.Core (2)
src\SignalR\common\Shared\TimerAwaitable.cs (2)
76var continuation = Interlocked.Exchange(ref _callback, _callbackCompleted); 83ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted))
Microsoft.AspNetCore.SignalR.Client.Tests (1)
TestConnection.cs (1)
206Interlocked.Increment(ref _disposeCount);
Microsoft.AspNetCore.SignalR.Core (2)
DefaultHubLifetimeManager.cs (1)
345var id = Interlocked.Increment(ref _lastInvocationId);
Internal\HubCallerClients.cs (1)
96return Interlocked.CompareExchange(ref _shouldReleaseSemaphore, 0, 1) == 1;
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
src\SignalR\common\testassets\Tests.Utils\TestClient.cs (1)
52var claimValue = Interlocked.Increment(ref _id).ToString(CultureInfo.InvariantCulture);
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
RedisHubLifetimeManager.cs (1)
348var id = Interlocked.Increment(ref _internalAckId);
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
TestConnectionMultiplexer.cs (1)
314_id = Interlocked.Increment(ref StaticId);
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
TestClient.cs (1)
52var claimValue = Interlocked.Increment(ref _id).ToString(CultureInfo.InvariantCulture);
Microsoft.Build (31)
BackEnd\BuildManager\BuildManager.cs (3)
1502return Interlocked.Increment(ref s_nextBuildId); 2205int newId = Interlocked.Increment(ref s_nextBuildRequestConfigurationId); 2212newId = Interlocked.Increment(ref s_nextBuildRequestConfigurationId);
BackEnd\BuildManager\BuildSubmission.cs (1)
195bool hasCompleted = (Interlocked.Exchange(ref _completionInvoked, 1) == 1);
BackEnd\Components\Communications\NodeManager.cs (1)
328fromNodeId = Interlocked.Add(ref _nextNodeId, numberOfNodesToCreate) - numberOfNodesToCreate;
BackEnd\Components\Logging\LoggingService.cs (4)
395return Interlocked.Add(ref _nextEvaluationId, MaxCPUCount + 2); 408return Interlocked.Add(ref _nextProjectId, MaxCPUCount + 2); 420return Interlocked.Increment(ref _nextTargetId); 432return Interlocked.Increment(ref _nextTaskId);
BackEnd\Components\RequestBuilder\RequestBuilder.cs (2)
1444var prev = Interlocked.CompareExchange(ref _availableThreads, count - 1, count); 1466Interlocked.Increment(ref _availableThreads);
BackEnd\Components\Scheduler\Scheduler.cs (1)
1391var loggedWarnings = Interlocked.CompareExchange(ref _loggedWarningsForProxyBuildsOnOutOfProcNodes, 1, 0);
BuildCheck\Infrastructure\BuildCheckManagerProvider.cs (1)
58Interlocked.CompareExchange(ref s_globalInstance, instance, null);
Construction\ProjectRootElement.cs (1)
2147Version = Interlocked.Increment(ref s_globalVersionCounter);
Definition\ProjectCollection.cs (2)
437if (Interlocked.CompareExchange(ref s_globalProjectCollection, local, null) != null) 845set => Interlocked.Exchange(ref _link, value)?.Disconnected(this);
Evaluation\ConditionEvaluator.cs (1)
160Interlocked.Increment(ref _mOptimisticSize);
Evaluation\Context\EvaluationContext.cs (1)
120if (Interlocked.CompareExchange(ref _used, 1, 0) == 0)
Graph\GraphBuildSubmission.cs (1)
133bool hasCompleted = (Interlocked.Exchange(ref _completionInvoked, 1) == 1);
Graph\ParallelWorkSet.cs (4)
119Interlocked.Increment(ref _pendingCount); 139while (!_cancellationToken.IsCancellationRequested && Interlocked.Read(ref _pendingCount) > 0) 173shouldStopAllWorkers = Interlocked.Read(ref _pendingCount) == 0 && IsCompleted; 205Interlocked.Decrement(ref _pendingCount);
Instance\TaskRegistry.cs (1)
720Interlocked.Increment(ref _nextRegistrationOrderId));
InterningBinaryReader.cs (2)
213Buffer buffer = Interlocked.Exchange(ref s_bufferPool, null); 232Interlocked.CompareExchange(ref s_bufferPool, _buffer, null);
Logging\BaseConsoleLogger.cs (2)
1208StringBuilder shared = Interlocked.Exchange(ref _sharedStringBuilder, null); 1265StringBuilder previous = Interlocked.CompareExchange(ref _sharedStringBuilder, builder, null);
TypeLoader.cs (3)
353if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 357if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 360Interlocked.Exchange(ref _haveScannedPublicTypes, ~0);
Microsoft.Build.Engine (10)
Engine\Engine.cs (2)
2009Interlocked.Increment(ref this.numberOfProjectsInProgress); 2034Interlocked.Decrement(ref this.numberOfProjectsInProgress);
Engine\TaskExecutionModule.cs (4)
546Interlocked.Increment(ref overallThreadCount); 551Interlocked.Decrement(ref overallThreadCount); 557Interlocked.Decrement(ref activeThreadCount); 563while (Interlocked.CompareExchange(ref activeThreadCount, 1, 0) != 0)
LocalProvider\LocalCallDescriptor.cs (1)
34this.callNumber = Interlocked.Increment(ref lastUsedCallNumber);
LocalProvider\LocalNodeProvider.cs (3)
518Interlocked.Decrement(ref activeNodeCount); 530Interlocked.Increment(ref activeNodeCount); 553Interlocked.Decrement(ref responseCount);
Microsoft.Build.Engine.OM.UnitTests (9)
Construction\ProjectRootElement_Tests.cs (8)
1029var current = Interlocked.Increment(ref counter) - 1; 1033if (Interlocked.Decrement(ref remaining) == 0) 1052var current = Interlocked.Increment(ref counter) - 1; 1058if (Interlocked.Decrement(ref remaining) == 0) 1100var current = Interlocked.Increment(ref counter) - 1; 1105if (Interlocked.Decrement(ref remaining) == 0) 1122var current = Interlocked.Increment(ref counter) - 1; 1126if (Interlocked.Decrement(ref remaining) == 0)
ObjectModelRemoting\RemoteProjectsProviderMock\ExporterMock.cs (1)
157this.CollectionId = (UInt32)Interlocked.Increment(ref _collecitonId);
Microsoft.Build.Engine.UnitTests (3)
ProjectCache\ProjectCacheTests.cs (3)
293var queryId = Interlocked.Increment(ref _nextId); 1596Interlocked.Increment(ref nonCacheHitCount); 1601Interlocked.Increment(ref cacheHitCount);
Microsoft.Build.Framework (8)
BuildException\BuildExceptionSerializationHelper.cs (1)
65if (Interlocked.Exchange(ref s_exceptionFactories, exceptionFactories) != null)
ImmutableSegmentedDictionary`2+PrivateInterlocked.cs (2)
28var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 37var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
ImmutableSegmentedList`1+PrivateInterlocked.cs (2)
28var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 37var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
Profiler\EvaluationIdProvider.cs (1)
30var nextId = Interlocked.Increment(ref _sAssignedId);
ReuseableStringBuilder.cs (2)
258StringBuilder? returned = Interlocked.Exchange(ref s_sharedBuilder, null); 339var oldSharedBuilder = Interlocked.Exchange(ref s_sharedBuilder, returningBuilder);
Microsoft.Build.Tasks.Core (3)
InterningBinaryReader.cs (2)
213Buffer buffer = Interlocked.Exchange(ref s_bufferPool, null); 232Interlocked.CompareExchange(ref s_bufferPool, _buffer, null);
System.Design.cs (1)
109Interlocked.CompareExchange(ref s_loader, sr, null);
Microsoft.Build.Tasks.UnitTests (1)
Copy_Tests.cs (1)
3016Interlocked.Increment(ref copyCount);
Microsoft.Build.UnitTests.Shared (1)
ObjectModelHelpers.cs (1)
2307Interlocked.Increment(ref incremented);
Microsoft.CSharp (1)
Microsoft\CSharp\RuntimeBinder\BinderEquivalence.cs (1)
41var count = Interlocked.Increment(ref cachedBinderCount);
Microsoft.DotNet.RemoteExecutor (2)
RemoteInvokeHandle.cs (2)
180Interlocked.CompareExchange(ref s_clrMdLock, 1, 0) == 0) // Make sure we only attach to one process at a time. 219Interlocked.Exchange(ref s_clrMdLock, 0);
Microsoft.Extensions.Caching.Hybrid (7)
Internal\DefaultHybridCache.CacheItem.cs (2)
44var newCount = Interlocked.Decrement(ref _refCount); 68var updated = Interlocked.CompareExchange(ref _refCount, oldValue + 1, oldValue);
Internal\DefaultHybridCache.Debug.cs (3)
28=> flush ? Interlocked.Exchange(ref _outstandingBufferCount, 0) : Volatile.Read(ref _outstandingBufferCount); 33Interlocked.Decrement(ref _outstandingBufferCount); 39Interlocked.Increment(ref _outstandingBufferCount);
Internal\RecyclableArrayBufferWriter.cs (2)
49var obj = Interlocked.Exchange(ref _spare, null) ?? new(); 67if (Interlocked.CompareExchange(ref _spare, this, null) != null)
Microsoft.Extensions.Caching.Hybrid.Tests (21)
L2Tests.cs (12)
154Interlocked.Increment(ref opcount); 161Interlocked.Increment(ref opcount); 168Interlocked.Increment(ref opcount); 181Interlocked.Increment(ref opcount); 203Interlocked.Increment(ref opcount); 210Interlocked.Increment(ref opcount); 217Interlocked.Increment(ref opcount); 224Interlocked.Increment(ref opcount); 231Interlocked.Increment(ref opcount); 238Interlocked.Increment(ref opcount); 245Interlocked.Increment(ref opcount); 252Interlocked.Increment(ref opcount);
RedisTests.cs (1)
91Interlocked.Increment(ref count);
StampedeTests.cs (8)
82using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 87Interlocked.Increment(ref executeCount); 116using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 121Interlocked.Increment(ref executeCount); 166using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 173Interlocked.Increment(ref executeCount); 238using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 245Interlocked.Increment(ref executeCount);
Microsoft.Extensions.Caching.Memory (14)
CacheEntry.CacheEntryTokens.cs (1)
117List<PostEvictionCallbackRegistration>? callbackRegistrations = Interlocked.Exchange(ref entry._tokens._postEvictionCallbacks, null);
CacheEntry.cs (1)
316return Interlocked.CompareExchange(ref _tokens, result, null) ?? result;
MemoryCache.cs (12)
174Interlocked.Add(ref coherentState._cacheSize, -priorEntry.Size); 195Interlocked.Add(ref coherentState._cacheSize, -entry.Size); 249Interlocked.Increment(ref GetStats().Hits); 270Interlocked.Increment(ref GetStats().Misses); 290Interlocked.Add(ref coherentState._cacheSize, -entry.Size); 307CoherentState oldState = Interlocked.Exchange(ref _coherentState, new CoherentState()); 372hits += Interlocked.Read(ref stats.Hits); 373misses += Interlocked.Read(ref stats.Misses); 413_accumulatedStats!.Hits += Interlocked.Read(ref current.Hits); 414_accumulatedStats.Misses += Interlocked.Read(ref current.Misses); 466long original = Interlocked.CompareExchange(ref coherentState._cacheSize, newSize, sizeRead); 677Interlocked.Add(ref _cacheSize, -entry.Size);
Microsoft.Extensions.Caching.MicroBenchmarks (2)
src\Caching\Hybrid\src\Internal\RecyclableArrayBufferWriter.cs (2)
49var obj = Interlocked.Exchange(ref _spare, null) ?? new(); 67if (Interlocked.CompareExchange(ref _spare, this, null) != null)
Microsoft.Extensions.Caching.StackExchangeRedis (2)
RedisCache.cs (2)
617ReleaseConnection(Interlocked.Exchange(ref _cache, null)); 669var tmp = Interlocked.CompareExchange(ref _cache, null, cache);
Microsoft.Extensions.Configuration (5)
ConfigurationManager.cs (1)
119var previousToken = Interlocked.Exchange(ref _changeToken, new ConfigurationReloadToken());
ConfigurationProvider.cs (1)
117ConfigurationReloadToken previousToken = Interlocked.Exchange(ref _reloadToken, new ConfigurationReloadToken());
ConfigurationRoot.cs (1)
94ConfigurationReloadToken previousToken = Interlocked.Exchange(ref _changeToken, new ConfigurationReloadToken());
ReferenceCountedProviders.cs (2)
64Interlocked.Increment(ref _refCount); 69if (Interlocked.Decrement(ref _refCount) == 0)
Microsoft.Extensions.DependencyInjection (1)
ServiceLookup\DynamicServiceProviderEngine.cs (1)
30if (Interlocked.Increment(ref callCount) == 2)
Microsoft.Extensions.Diagnostics (1)
Metrics\DebugConsoleMetricListener.cs (1)
32if (instrument.IsObservable && Interlocked.Exchange(ref _timerStarted, 1) == 0)
Microsoft.Extensions.Logging.Abstractions (1)
FormattedLogValues.cs (1)
46Interlocked.Increment(ref s_count);
Microsoft.Extensions.Logging.AzureAppServices (2)
BatchingLoggerProvider.cs (2)
100var messagesDropped = Interlocked.Exchange(ref _messagesDropped, 0); 145Interlocked.Increment(ref _messagesDropped);
Microsoft.Extensions.Logging.EventSource (3)
EventSourceLogger.cs (1)
128int id = Interlocked.Increment(ref _activityIds);
EventSourceLoggerProvider.cs (1)
32_factoryID = Interlocked.Increment(ref _globalFactoryID);
LoggingEventSource.cs (1)
340CancellationTokenSource? tcs = Interlocked.Exchange(ref _cancellationTokenSource, null);
Microsoft.Extensions.ObjectPool (5)
DefaultObjectPool.cs (5)
51if (item == null || Interlocked.CompareExchange(ref _fastItem, null, item) != item) 55Interlocked.Decrement(ref _numItems); 84if (_fastItem != null || Interlocked.CompareExchange(ref _fastItem, obj, null) != null) 86if (Interlocked.Increment(ref _numItems) <= _maxCapacity) 93Interlocked.Decrement(ref _numItems);
Microsoft.Extensions.Options (1)
UnnamedOptionsManager.cs (1)
28lock (_syncObj ?? Interlocked.CompareExchange(ref _syncObj, new object(), null) ?? _syncObj)
Microsoft.Extensions.Primitives (2)
ChangeToken.cs (2)
125IDisposable? previous = Interlocked.CompareExchange(ref _disposable, disposable, current); 147Interlocked.Exchange(ref _disposable, _disposedSentinel)?.Dispose();
Microsoft.JSInterop (3)
JSRuntime.cs (3)
104var taskId = Interlocked.Increment(ref _nextPendingTaskId); 286var streamId = Interlocked.Increment(ref _nextObjectReferenceId); 304var dotNetObjectId = Interlocked.Increment(ref _nextObjectReferenceId);
Microsoft.NET.StringTools (1)
WeakStringCache.Concurrent.cs (1)
73if (Interlocked.CompareExchange(ref _scavengeThreshold, int.MaxValue, scavengeThreshold) == scavengeThreshold)
MonoAOTCompiler (1)
MonoAOTCompiler.cs (1)
1053int count = Interlocked.Increment(ref _numCompiled);
MonoTargetsTasks (1)
EmitBundleTask\EmitBundleBase.cs (1)
173var count = Interlocked.Increment(ref verboseCount);
MSBuild (5)
InterningBinaryReader.cs (2)
213Buffer buffer = Interlocked.Exchange(ref s_bufferPool, null); 232Interlocked.CompareExchange(ref s_bufferPool, _buffer, null);
TypeLoader.cs (3)
353if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 357if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 360Interlocked.Exchange(ref _haveScannedPublicTypes, ~0);
MSBuildTaskHost (11)
BuildExceptionSerializationHelper.cs (1)
65if (Interlocked.Exchange(ref s_exceptionFactories, exceptionFactories) != null)
Concurrent\ConcurrentDictionary.cs (2)
208Interlocked.Exchange(ref tables._buckets[bucketNo], newNode); 227Interlocked.Exchange(ref tables._buckets[bucketNo], new Node(key, value, hashcode, tables._buckets[bucketNo]));
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)
InterningBinaryReader.cs (2)
213Buffer buffer = Interlocked.Exchange(ref s_bufferPool, null); 232Interlocked.CompareExchange(ref s_bufferPool, _buffer, null);
TypeLoader.cs (3)
262if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 266if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 269Interlocked.Exchange(ref _haveScannedPublicTypes, ~0);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
1132[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Interlocked))]
netstandard (1)
netstandard.cs (1)
2081[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Interlocked))]
PresentationCore (13)
MS\Internal\FontCache\BufferCache.cs (6)
40if (Interlocked.Increment(ref _mutex) == 1) 44Interlocked.Decrement(ref _mutex); 169if (Interlocked.Increment(ref _mutex) == 1) 179Interlocked.Decrement(ref _mutex); 197if (Interlocked.Increment(ref _mutex) == 1) 210Interlocked.Decrement(ref _mutex);
System\Windows\EventHelper.cs (2)
31if (Interlocked.CompareExchange(ref field, newTuple, oldTuple) == oldTuple) 48if (Interlocked.CompareExchange(ref field, newTuple, oldTuple) == oldTuple)
System\Windows\Media\MediaContext.cs (1)
2049uint renderID = (uint)Interlocked.Increment(ref _contextRenderID);
System\Windows\Media\MediaSystem.cs (1)
165if (System.Threading.Interlocked.CompareExchange(ref s_DisableDirtyRectangles, disableDirtyRectangles, oldValue) == oldValue)
System\Windows\Media\SafeMILHandleMemoryPressure.cs (2)
33Interlocked.Increment(ref _refCount); 38if (Interlocked.Decrement(ref _refCount) == 0)
System\Windows\Media\textformatting\TextFormatterContext.cs (1)
487System.Threading.Interlocked.CompareExchange<Dictionary<char,bool>>(ref _specialCharacters, dict, null);
PresentationFramework (22)
MS\Internal\Data\CollectionViewProxy.cs (2)
173IndexedEnumerable indexer = (IndexedEnumerable)Interlocked.Exchange(ref _indexer, null); 1061Interlocked.CompareExchange(ref _indexer, newIndexer, null);
MS\Internal\Data\DataBindEngine.cs (3)
439if (Interlocked.Increment(ref _cleanupRequests) == 1) 603Interlocked.Exchange(ref _cleanupRequests, 0); 627HybridDictionary asyncDispatchers = (HybridDictionary)Interlocked.Exchange(ref _asyncDispatchers, null);
MS\Internal\PtsHost\FlowDocumentPage.cs (1)
809if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PageBreakRecord.cs (1)
137if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsCache.cs (2)
169if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0)) 296if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0))
MS\Internal\PtsHost\PtsContext.cs (1)
78if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsPage.cs (1)
714if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\Utility\MonitorWrapper.cs (2)
27Interlocked.Increment(ref _enterCount); 33int count = Interlocked.Decrement(ref _enterCount);
MS\Win32\UxThemeWrapper.cs (1)
223ThemeState currentState = System.Threading.Interlocked.CompareExchange(ref _themeState, newState, themeState);
System\Windows\Data\BindingOperations.cs (2)
573Interlocked.CompareExchange<ExceptionLogger>(ref _exceptionLogger, newLogger, null); 600Interlocked.CompareExchange<ExceptionLogger>(ref _exceptionLogger, null, this);
System\Windows\Data\CollectionView.cs (2)
1441IndexedEnumerable wrapper = (IndexedEnumerable) Interlocked.Exchange(ref _enumerableWrapper, null); 1757Interlocked.CompareExchange(ref _enumerableWrapper, newWrapper, null);
System\Windows\Documents\WpfPayload.cs (1)
322int newWpfPayoutCount = Interlocked.Increment(ref _wpfPayloadCount);
System\Windows\FrameworkElementFactory.cs (1)
1157Interlocked.Increment(ref AutoGenChildNamePostfix);
System\Windows\StyleHelper.cs (1)
5344Interlocked.Increment(ref lastChildIndex);
System\Windows\SystemResources.cs (1)
844string currentName = System.Threading.Interlocked.CompareExchange(ref _themedResourceName, themedResourceName, null);
SignalR.Client.FunctionalTestApp (1)
Startup.cs (1)
170var newUrl = context.Request.Query["baseUrl"] + "/testHub?numRedirects=" + Interlocked.Increment(ref _numRedirects);
Sockets.FunctionalTests (1)
src\Servers\Kestrel\test\FunctionalTests\RequestTests.cs (1)
200if (Interlocked.Increment(ref requestNumber) == 1)
System.Collections (1)
System\Collections\Generic\SortedSet.cs (1)
9using Interlocked = System.Threading.Interlocked;
System.Collections.Concurrent (22)
System\Collections\Concurrent\BlockingCollection.cs (3)
456if (Interlocked.CompareExchange(ref _currentAdders, observedAdders + 1, observedAdders) == observedAdders) 493Interlocked.Decrement(ref _currentAdders); 1456if (Interlocked.CompareExchange(ref _currentAdders, observedAdders | COMPLETE_ADDING_ON_MASK, observedAdders) == observedAdders)
System\Collections\Concurrent\ConcurrentBag.cs (8)
207long initialEmptyToNonEmptyCounts = Interlocked.Read(ref _emptyToNonEmptyListTransitionCount); 227if (Interlocked.Read(ref _emptyToNonEmptyListTransitionCount) == initialEmptyToNonEmptyCounts) 626Interlocked.MemoryBarrier(); // prevent reads of _currentOp from moving before writes to _frozen 729Interlocked.Exchange(ref _currentOp, (int)Operation.Add); 752Interlocked.Exchange(ref _currentOp, (int)Operation.Add); // ensure subsequent reads aren't reordered before this 819Interlocked.Increment(ref emptyToNonEmptyListTransitionCount); 878Interlocked.Exchange(ref _tailIndex, --tail); 991Interlocked.Exchange(ref _headIndex, unchecked(head + 1));
System\Collections\Concurrent\ConcurrentStack.cs (5)
282if (Interlocked.CompareExchange(ref _head, newNode, newNode._next) == newNode._next) 351if (Interlocked.CompareExchange(ref _head, head, tail._next) == tail._next) 378while (Interlocked.CompareExchange( 468if (Interlocked.CompareExchange(ref _head, head._next, head) == head) 611if (Interlocked.CompareExchange(ref _head, next._next, head) == head)
System\Collections\Concurrent\PartitionerStatic.cs (6)
643Interlocked.Increment(ref _activeCopiers); 645int endPos = Interlocked.Add(ref _fillBufferCurrentPosition, requestedChunkSize); 656Interlocked.Decrement(ref _activeCopiers); 897Interlocked.Increment(ref _activePartitionCount.Value); 960if (_activePartitionCount != null && Interlocked.Decrement(ref _activePartitionCount.Value) == 0) 1106if (Interlocked.CompareExchange(ref _sharedIndex.Value, newSharedIndex, oldSharedIndex)
System.Collections.Immutable (21)
System\Collections\Immutable\ImmutableDictionary_2.Builder.cs (1)
260Threading.Interlocked.CompareExchange<object?>(ref _syncRoot, new object(), null);
System\Collections\Immutable\ImmutableInterlocked.cs (16)
49T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue); 93T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue); 135T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 179T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 199return new ImmutableArray<T>(Interlocked.Exchange(ref Unsafe.AsRef(in location.array), value.array)); 213return new ImmutableArray<T>(Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), value.array, comparand.array)); 313ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 361ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 408ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 442ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 477ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 508ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 542ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 565ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 597ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 620ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
System\Collections\Immutable\ImmutableList_1.Builder.cs (1)
1179System.Threading.Interlocked.CompareExchange<object?>(ref _syncRoot, new object(), null);
System\Collections\Immutable\ImmutableSortedDictionary_2.Builder.cs (1)
271Threading.Interlocked.CompareExchange<object?>(ref _syncRoot, new object(), null);
System\Collections\Immutable\ImmutableSortedSet_1.Builder.cs (1)
514Threading.Interlocked.CompareExchange<object?>(ref _syncRoot, new object(), null);
System\Collections\Immutable\SecureObjectPool.cs (1)
33result = Interlocked.Increment(ref s_poolUserIdCounter);
System.ComponentModel.Composition (12)
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\Primitives\ComposablePartCatalog.cs (1)
61Interlocked.CompareExchange(ref _queryableParts, p, null);
System\ComponentModel\Composition\Primitives\Export.cs (1)
205Interlocked.CompareExchange(ref _exportedValue, exportedValue, Export._EmptyValue);
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.ComponentModel.TypeConverter (7)
System\ComponentModel\InterlockedBitVector32.cs (2)
25Interlocked.Or(ref _data, bit); 29Interlocked.And(ref _data, ~bit);
System\ComponentModel\LicenseManager.cs (2)
89Interlocked.CompareExchange(ref s_providers, new Hashtable(), null); 101Interlocked.CompareExchange(ref s_providerInstances, new Hashtable(), null);
System\ComponentModel\TypeDescriptor.cs (3)
1164int ci = System.Threading.Interlocked.Increment(ref s_collisionIndex) - 1; 2199Interlocked.Increment(ref s_metadataVersion); 2265Interlocked.Increment(ref s_metadataVersion);
System.Composition.Hosting (1)
System\Composition\Hosting\Core\LifetimeContext.cs (1)
51return Interlocked.Increment(ref s_nextSharingId);
System.Console (2)
System\ConsolePal.Unix.cs (2)
92Interlocked.CompareExchange(ref s_stdInReader, reader, null); 1103bool invalidateSettings = Interlocked.CompareExchange(ref s_invalidateCachedSettings, 0, 1) == 1;
System.Data.Common (13)
System\Data\Common\DataAdapter.cs (1)
31internal readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\Common\DataCommonEventSource.cs (1)
75scopeId = Interlocked.Increment(ref s_nextScopeId);
System\Data\Common\DbConnectionStringBuilder.cs (1)
36internal readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataColumn.cs (1)
75private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataRelation.cs (1)
71private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataRelationCollection.cs (1)
30private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataRow.cs (1)
40internal readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataSet.cs (1)
74private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataTable.cs (2)
159private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount); 1255view = Interlocked.CompareExchange(ref _defaultView, view, null);
System\Data\DataTableCollection.cs (1)
31private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\DataView.cs (1)
95private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\Selection.cs (1)
86private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount);
System.Diagnostics.DiagnosticSource (37)
System\Diagnostics\Activity.cs (15)
234Interlocked.CompareExchange(ref _id, id, null); 266Interlocked.CompareExchange(ref _parentId, parentId, null); 270Interlocked.CompareExchange(ref _parentId, Parent.Id, null); 305Interlocked.CompareExchange(ref _rootId, rootId, null); 473if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp), null) != null) 497if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp, set: true), null) != null) 512if (_events != null || Interlocked.CompareExchange(ref _events, new DiagLinkedList<ActivityEvent>(e), null) != null) 531if (_links != null || Interlocked.CompareExchange(ref _links, new DiagLinkedList<ActivityLink>(link), null) != null) 552if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp), null) != null) 576if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp, set: true), null) != null) 832Interlocked.CompareExchange(ref _spanId, spanId, null); 912Interlocked.CompareExchange(ref _parentSpanId, parentSpanId, null); 1053Interlocked.CompareExchange(ref _customProperties, new Dictionary<string, object>(), null); 1228ret = AppendSuffix(Parent.Id, Interlocked.Increment(ref Parent._currentChildId).ToString(), '.'); 1245ret = AppendSuffix(parentId, Interlocked.Increment(ref s_currentRootId).ToString("x"), '_');
System\Diagnostics\Activity.GenerateRootId.netcoreapp.cs (1)
19bool formatted = Interlocked.Increment(ref s_currentRootId).TryFormat(result.Slice(1), out int charsWritten, "x");
System\Diagnostics\ActivitySource.cs (1)
331Interlocked.CompareExchange(ref _listeners, new SynchronizedList<ActivityListener>(), null);
System\Diagnostics\DiagnosticListener.cs (4)
44Interlocked.CompareExchange(ref s_allListenerObservable, new AllListenerObservable(), null) ?? 186subscriber = Interlocked.Exchange(ref _subscriptions, subscriber); 295if (Interlocked.CompareExchange(ref Owner._subscriptions, newSubscriptions, subscriptions) == subscriptions) 449while (Interlocked.CompareExchange(ref _subscriptions, newSubscription, newSubscription.Next) != newSubscription.Next)
System\Diagnostics\DiagnosticSourceEventSource.cs (2)
1046Interlocked.CompareExchange(ref _firstImplicitTransformsEntry, 1057Interlocked.CompareExchange(ref _implicitTransformsTable,
System\Diagnostics\Metrics\AggregatorStore.cs (9)
141if (Interlocked.CompareExchange(ref _stateUnion, newState, null) is null) 158if (Interlocked.CompareExchange(ref _stateUnion, newState, state) == state) 177if (Interlocked.CompareExchange(ref _stateUnion, newState, null) is null) 194if (Interlocked.CompareExchange(ref _stateUnion, newState, state) == state) 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\Metrics\CounterAggregator.cs (2)
51while (Interlocked.CompareExchange(ref delta.Value, currentValue + value, currentValue) != currentValue); 64delta += Interlocked.Exchange(ref paddedDelta.Value, 0);
System\Diagnostics\Metrics\MetricsEventSource.cs (3)
81Interlocked.CompareExchange(ref _handler, new CommandHandler(this), null); 471&& ((!_disabledRefCount && Interlocked.Decrement(ref _sharedSessionRefCount) == 0) 514Interlocked.Increment(ref _sharedSessionRefCount);
System.Diagnostics.Process (3)
System\Diagnostics\Process.ConfigureTerminalForChildProcesses.Unix.cs (1)
17int childrenUsingTerminalRemaining = Interlocked.Add(ref s_childrenUsingTerminalCount, increment);
System\Diagnostics\Process.Linux.cs (2)
89long bootTimeTicks = Interlocked.Read(ref s_bootTimeTicks); 93long oldValue = Interlocked.CompareExchange(ref s_bootTimeTicks, bootTimeTicks, 0);
System.Diagnostics.TraceSource (2)
System\Diagnostics\Switch.cs (1)
41Interlocked.CompareExchange<object?>(ref _initializedLock, o, null);
System\Diagnostics\Trace.cs (1)
25Interlocked.CompareExchange(ref s_correlationManager, new CorrelationManager(), null) ??
System.Formats.Cbor (1)
System\Formats\Cbor\Reader\CborReader.String.cs (1)
520List<(int Offset, int Length)>? ranges = Interlocked.Exchange(ref _indefiniteLengthStringRangeAllocation, null);
System.IO.Compression (4)
System\IO\Compression\DeflateManaged\DeflateManagedStream.cs (3)
167Interlocked.Increment(ref _asyncOperations); 198Interlocked.Decrement(ref _asyncOperations); 244Interlocked.Decrement(ref _asyncOperations);
System\IO\Compression\DeflateZLib\DeflateStream.cs (1)
1072if (Interlocked.Exchange(ref _activeAsyncOperation, 1) != 0)
System.IO.Compression.Brotli (1)
System\IO\Compression\BrotliStream.cs (1)
184if (Interlocked.Exchange(ref _activeAsyncOperation, 1) != 0)
System.IO.Pipelines (2)
System\IO\Pipelines\SequencePipeReader.cs (2)
46Interlocked.Exchange(ref _cancelNext, 1); 78bool isCancellationRequested = Interlocked.Exchange(ref _cancelNext, 0) == 1;
System.IO.Pipes (2)
Microsoft\Win32\SafeHandles\SafePipeHandle.Unix.cs (1)
113Socket? current = Interlocked.CompareExchange(ref _pipeSocket, socket, null);
System\IO\Pipes\NamedPipeServerStream.Unix.cs (1)
138Interlocked.Exchange(ref _instance, null)?.Dispose(disposing); // interlocked to avoid shared state problems from erroneous double/concurrent disposes
System.Linq.Expressions (11)
System\Dynamic\Utils\DelegateHelpers.cs (1)
233int thunkIndex = Interlocked.Increment(ref s_ThunksCreated);
System\Dynamic\Utils\ExpressionUtils.cs (3)
24Interlocked.CompareExchange( 46Interlocked.CompareExchange(ref collection, value.ToReadOnly(), value); 71Interlocked.CompareExchange(
System\Linq\Expressions\BlockExpression.cs (1)
175Interlocked.CompareExchange(
System\Linq\Expressions\Compiler\AssemblyGen.cs (2)
28Interlocked.CompareExchange(ref s_assembly, new AssemblyGen(), comparand: null); 49int index = Interlocked.Increment(ref _index);
System\Linq\Expressions\Compiler\LambdaCompiler.cs (1)
73int lambdaMethodIndex = Interlocked.Increment(ref s_lambdaMethodIndex);
System\Linq\Expressions\Expression.cs (1)
66Interlocked.CompareExchange(
System\Runtime\CompilerServices\CallSite.cs (1)
190matchmaker = Interlocked.Exchange(ref _cachedMatchmaker, null);
System\Runtime\CompilerServices\CallSiteBinder.cs (1)
207Interlocked.CompareExchange(ref Cache, new Dictionary<Type, object>(), null);
System.Linq.Parallel (9)
System\Linq\Parallel\Channels\AsynchronousChannel.cs (4)
305Interlocked.Exchange(ref _producerBufferIndex, (bufferIndex + 1) % _buffer.Length); 344Interlocked.Exchange(ref _producerIsWaiting, 1); 561Interlocked.Exchange(ref _consumerIsWaiting, 1); 621Interlocked.Exchange(ref _consumerBufferIndex, (consumerBufferIndex + 1) % _buffer.Length);
System\Linq\Parallel\Partitioning\PartitionedDataSource.cs (1)
703if (Interlocked.Decrement(ref _activeEnumeratorsCount.Value) == 0)
System\Linq\Parallel\QueryOperators\Unary\DefaultIfEmptyQueryOperator.cs (1)
190Interlocked.Increment(ref _sharedEmptyCount.Value);
System\Linq\Parallel\QueryOperators\Unary\SingleQueryOperator.cs (1)
157Interlocked.Increment(ref _totalElementCount.Value);
System\Linq\Parallel\Scheduling\QueryTaskGroupState.cs (1)
89if (Interlocked.Exchange(ref _alreadyEnded, 1) == 0)
System\Linq\Parallel\Utils\PLINQETWProvider.cs (1)
45return Interlocked.Increment(ref s_queryId);
System.Net.Http (47)
System\Net\Http\Headers\CacheControlHeaderValue.cs (2)
73Interlocked.Or(ref Unsafe.As<Flags, int>(ref _flags), (int)flag); 77Interlocked.And(ref Unsafe.As<Flags, int>(ref _flags), (int)~flag);
System\Net\Http\HttpClient.cs (1)
688CancellationTokenSource currentCts = Interlocked.Exchange(ref _pendingRequestsCts, new CancellationTokenSource());
System\Net\Http\HttpClientHandler.cs (1)
367Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
System\Net\Http\HttpRequestMessage.cs (1)
171internal bool MarkAsSent() => Interlocked.CompareExchange(ref _sendStatus, MessageAlreadySent, MessageNotYetSent) == MessageNotYetSent;
System\Net\Http\HttpTelemetry.AnyOS.cs (9)
51_startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests)) 57_startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests)) 67_failedRequestsCounter ??= new PollingCounter("requests-failed", this, () => Interlocked.Read(ref _failedRequests)) 73_failedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-failed-rate", this, () => Interlocked.Read(ref _failedRequests)) 82_currentRequestsCounter ??= new PollingCounter("current-requests", this, () => -Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests)) 87_totalHttp11ConnectionsCounter ??= new PollingCounter("http11-connections-current-total", this, () => Interlocked.Read(ref _openedHttp11Connections)) 92_totalHttp20ConnectionsCounter ??= new PollingCounter("http20-connections-current-total", this, () => Interlocked.Read(ref _openedHttp20Connections)) 97_totalHttp30ConnectionsCounter ??= new PollingCounter("http30-connections-current-total", this, () => Interlocked.Read(ref _openedHttp30Connections))
System\Net\Http\HttpTelemetry.cs (9)
39Interlocked.Increment(ref _startedRequests); 67Interlocked.Increment(ref _stoppedRequests); 74Interlocked.Increment(ref _failedRequests); 181Interlocked.Increment(ref _openedHttp11Connections); 188long count = Interlocked.Decrement(ref _openedHttp11Connections); 196Interlocked.Increment(ref _openedHttp20Connections); 203long count = Interlocked.Decrement(ref _openedHttp20Connections); 211Interlocked.Increment(ref _openedHttp30Connections); 218long count = Interlocked.Decrement(ref _openedHttp30Connections);
System\Net\Http\Metrics\HttpMetricsEnrichmentContext.cs (3)
89Interlocked.Decrement(ref s_poolItemCount); 150if (Interlocked.Increment(ref s_poolItemCount) <= PoolCapacity) 156Interlocked.Decrement(ref s_poolItemCount);
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.cs (1)
427Interlocked.CompareExchange(ref _sslOptionsHttp3, sslOptionsHttp3, null);
System\Net\Http\SocketsHttpHandler\FailedProxyCache.cs (2)
96if (_failedProxies.Count > LargeProxyConfigBoundary && Environment.TickCount64 >= Interlocked.Read(ref _nextFlushTicks)) 136Interlocked.Exchange(ref _nextFlushTicks, Environment.TickCount64 + FlushFailuresTimerInMilliseconds);
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (4)
187Interlocked.CompareExchange(ref _initialSettingsReceived, new(), null) ?? 903Interlocked.CompareExchange(ref _initialSettingsReceived, s_settingsReceivedSingleton, null); 2102if (Interlocked.Read(ref _keepAlivePingPayload) != payload) 2132long pingPayload = Interlocked.Increment(ref _keepAlivePingPayload);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (1)
1575Http2Stream? http2Stream = Interlocked.Exchange(ref _http2Stream, null);
System\Net\Http\SocketsHttpHandler\Http2StreamWindowManager.cs (1)
275Interlocked.Exchange(ref _minRtt, minRtt); // MinRtt is being queried from another thread
System\Net\Http\SocketsHttpHandler\Http3Connection.cs (4)
262Exception? firstException = Interlocked.CompareExchange(ref _abortException, abortException, null); 516if (Interlocked.Exchange(ref _haveServerControlStream, 1) != 0) 532if (Interlocked.Exchange(ref _haveServerQpackDecodeStream, 1) != 0) 543if (Interlocked.Exchange(ref _haveServerQpackEncodeStream, 1) != 0)
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (2)
1357Http3RequestStream? stream = Interlocked.Exchange(ref _stream, null); 1384Http3RequestStream? stream = Interlocked.Exchange(ref _stream, null);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (2)
102if (Interlocked.Exchange(ref _disposed, Status_Disposed) != Status_Disposed) 200Interlocked.CompareExchange(ref _readAheadTaskStatus, ReadAheadTask_CompletionReserved, ReadAheadTask_Started) == ReadAheadTask_Started;
System\Net\Http\SocketsHttpHandler\HttpConnectionBase.cs (1)
36public long Id { get; } = Interlocked.Increment(ref s_connectionCounter);
System\Net\Http\SocketsHttpHandler\HttpConnectionPoolManager.cs (1)
170if (Interlocked.CompareExchange(ref _networkChangeCleanup, cleanup, null) != null)
System\Net\Http\SocketsHttpHandler\HttpContentReadStream.cs (1)
55if (Interlocked.Exchange(ref _disposed, 1) != 0)
System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs (1)
543if (Interlocked.CompareExchange(ref _handler, handler, null) != null)
System.Net.HttpListener (12)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (6)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 146if (Interlocked.CompareExchange(ref _event, waitHandle, null) == null) 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 310if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1) 489if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1)
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.Mail (12)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (6)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 146if (Interlocked.CompareExchange(ref _event, waitHandle, null) == null) 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 310if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1) 489if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1)
System\Net\CloseableStream.cs (1)
22if (Interlocked.Increment(ref _closed) == 1)
System\Net\Mail\SmtpClient.cs (2)
753if (Interlocked.Exchange(ref state, 1) != 0) 786if (Interlocked.Exchange(ref state, 1) != 0)
System\Net\Mime\MimeMultiPart.cs (1)
238int b = Interlocked.Increment(ref s_boundary) - 1;
System\Net\Mime\MultiAsyncResult.cs (2)
32if (Interlocked.Decrement(ref _outstanding) == -1) 38private void Increment() => Interlocked.Increment(ref _outstanding);
System.Net.NameResolution (5)
System\Net\NameResolutionTelemetry.cs (5)
33_lookupsRequestedCounter ??= new PollingCounter("dns-lookups-requested", this, () => Interlocked.Read(ref _lookupsRequested)) 39_currentLookupsCounter ??= new PollingCounter("current-dns-lookups", this, () => Interlocked.Read(ref _currentLookups)) 67Interlocked.Increment(ref _lookupsRequested); 68Interlocked.Increment(ref _currentLookups); 96Interlocked.Decrement(ref _currentLookups);
System.Net.Quic (18)
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeHandleCache.cs (1)
29T? currentHandle = Interlocked.CompareExchange(ref s_invalidHandle, newHandle, null);
src\libraries\Common\src\System\Net\StreamBuffer.cs (2)
315if (Interlocked.Exchange(ref _hasWaiter, 0) == 1) 325if (Interlocked.Exchange(ref _hasWaiter, 0) == 1)
System\Net\Quic\Internal\MsQuicSafeHandle.cs (3)
170} while (Interlocked.CompareExchange(ref _rentCount, oldCount + 1, oldCount) != oldCount); 177return Interlocked.CompareExchange(ref _rentCount, -1, 0) == 0; 182if (Interlocked.Decrement(ref _rentCount) < 0)
System\Net\Quic\QuicConnection.cs (1)
684if (Interlocked.Exchange(ref _disposed, 1) != 0)
System\Net\Quic\QuicListener.cs (4)
180Interlocked.Increment(ref _pendingConnectionsCapacity); 326if (Interlocked.Decrement(ref _pendingConnectionsCapacity) < 0) 333Interlocked.Increment(ref _pendingConnectionsCapacity); 408if (Interlocked.Exchange(ref _disposed, 1) != 0)
System\Net\Quic\QuicStream.cs (7)
324if (totalCopied > 0 && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) 399if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 419Interlocked.CompareExchange(ref _sendException, exception, null); 485Interlocked.CompareExchange(ref _sendException, exception, null); 486if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 561return (_receiveBuffers.HasCapacity() && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) ? QUIC_STATUS_CONTINUE : QUIC_STATUS_SUCCESS; 700if (Interlocked.Exchange(ref _disposed, 1) != 0)
System.Net.Requests (17)
src\libraries\Common\src\System\Net\LazyAsyncResult.cs (6)
122Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 146if (Interlocked.CompareExchange(ref _event, waitHandle, null) == null) 204result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 229result = Interlocked.CompareExchange(ref _intCompleted, HighBit, 0); 310if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1) 489if ((_intCompleted & ~HighBit) == 0 && (Interlocked.Increment(ref _intCompleted) & ~HighBit) == 1)
System\Net\FileWebRequest.cs (1)
295if (Interlocked.Increment(ref _aborted) == 1)
System\Net\HttpWebRequest.cs (5)
991if (Interlocked.Exchange(ref _abortCalled, 1) != 0) 1121if (Interlocked.Exchange(ref _beginGetRequestStreamCalled, 1) != 0) 1143if (Interlocked.Exchange(ref _endGetRequestStreamCalled, 1) != 0) 1394if (Interlocked.Exchange(ref _beginGetResponseCalled, 1) != 0) 1414if (Interlocked.Exchange(ref _endGetResponseCalled, 1) != 0)
System\Net\TimerThread.cs (5)
455internal override bool Cancel() => Interlocked.Exchange(ref _cancelled, 1) == 0; 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 (39)
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeHandleCache.cs (1)
29T? currentHandle = Interlocked.CompareExchange(ref s_invalidHandle, newHandle, null);
src\libraries\Common\src\System\Net\Security\SSPIHandleCache.cs (2)
28int index = Interlocked.Increment(ref s_current) & MaxCacheSize; 30Interlocked.Exchange(ref s_cacheSlots[index], newRef)?.Dispose();
System\Net\Security\NegotiateStream.cs (3)
343if (Interlocked.Exchange(ref _readInProgress, 1) == 1) 509if (Interlocked.Exchange(ref _writeInProgress, 1) == 1) 727if (Interlocked.Exchange(ref _authInProgress, 1) == 1)
System\Net\Security\NetSecurityTelemetry.cs (21)
46_tlsHandshakeRateCounter ??= new IncrementingPollingCounter("tls-handshake-rate", this, () => Interlocked.Read(ref _finishedTlsHandshakes)) 52_totalTlsHandshakesCounter ??= new PollingCounter("total-tls-handshakes", this, () => Interlocked.Read(ref _finishedTlsHandshakes)) 57_currentTlsHandshakesCounter ??= new PollingCounter("current-tls-handshakes", this, () => -Interlocked.Read(ref _finishedTlsHandshakes) + Interlocked.Read(ref _startedTlsHandshakes)) 62_failedTlsHandshakesCounter ??= new PollingCounter("failed-tls-handshakes", this, () => Interlocked.Read(ref _failedTlsHandshakes)) 67_sessionsOpenCounter ??= new PollingCounter("all-tls-sessions-open", this, () => Interlocked.Read(ref _sessionsOpen)) 72_sessionsOpenTls10Counter ??= new PollingCounter("tls10-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls10)) 77_sessionsOpenTls11Counter ??= new PollingCounter("tls11-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls11)) 82_sessionsOpenTls12Counter ??= new PollingCounter("tls12-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls12)) 87_sessionsOpenTls13Counter ??= new PollingCounter("tls13-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls13)) 128Interlocked.Increment(ref _startedTlsHandshakes); 156Interlocked.Increment(ref _finishedTlsHandshakes); 157Interlocked.Increment(ref _failedTlsHandshakes); 170Interlocked.Increment(ref _finishedTlsHandshakes); 205Interlocked.Increment(ref protocolSessionsOpen); 206Interlocked.Increment(ref _sessionsOpen); 225count = Interlocked.Decrement(ref _sessionsOpenTls10); 229count = Interlocked.Decrement(ref _sessionsOpenTls11); 234count = Interlocked.Decrement(ref _sessionsOpenTls12); 238count = Interlocked.Decrement(ref _sessionsOpenTls13); 244count = Interlocked.Decrement(ref _sessionsOpen);
System\Net\Security\SslStream.cs (2)
723var manager = Interlocked.Exchange(ref field, null) ?? new PoolingPointerMemoryManager(); 738if (Interlocked.Exchange(ref _nestedRead, StreamInUse) == StreamInUse)
System\Net\Security\SslStream.IO.cs (10)
61if (Interlocked.Exchange(ref _nestedRead, StreamDisposed) == StreamNotInUse && 62Interlocked.Exchange(ref _nestedAuth, StreamDisposed) == StreamNotInUse) 76if (Interlocked.Exchange(ref _connectionOpenedStatus, 2) == 1) 136bool connectionOpen = Interlocked.CompareExchange(ref _connectionOpenedStatus, 1, 0) == 0; 168if (Interlocked.CompareExchange(ref _nestedAuth, StreamInUse, StreamNotInUse) != StreamNotInUse) 174if (Interlocked.CompareExchange(ref _nestedRead, StreamInUse, StreamNotInUse) != StreamNotInUse) 181if (Interlocked.Exchange(ref _nestedWrite, StreamInUse) != StreamNotInUse) 265if (Interlocked.Exchange(ref _nestedAuth, StreamInUse) == StreamInUse) 802if (Interlocked.CompareExchange(ref _nestedRead, StreamInUse, StreamNotInUse) != StreamNotInUse) 944if (Interlocked.Exchange(ref _nestedWrite, StreamInUse) == StreamInUse)
System.Net.Sockets (56)
System\Net\Sockets\NetworkStream.cs (1)
372if (Interlocked.Exchange(ref _disposed, 1) != 0)
System\Net\Sockets\SafeSocketHandle.cs (1)
58=> Interlocked.CompareExchange(ref _ownClose, 1, 0) == 0;
System\Net\Sockets\SafeSocketHandle.Unix.cs (1)
101Interlocked.CompareExchange(ref _asyncContext, new SocketAsyncContext(this), null) ??
System\Net\Sockets\Socket.cs (1)
3242if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 1)
System\Net\Sockets\Socket.Tasks.cs (20)
62Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 95Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? 262Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 320Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? 348TaskSocketAsyncEventArgs<int>? saea = Interlocked.Exchange(ref _multiBufferReceiveEventArgs, null); 410Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? 450Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? 511Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ?? 566Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 584Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 612TaskSocketAsyncEventArgs<int>? saea = Interlocked.Exchange(ref _multiBufferSendEventArgs, null); 674Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 704Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 782Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ?? 945if (Interlocked.CompareExchange(ref cache, saea, null) != null) 954Interlocked.Exchange(ref _multiBufferReceiveEventArgs, null)?.Dispose(); 955Interlocked.Exchange(ref _multiBufferSendEventArgs, null)?.Dispose(); 956Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null)?.Dispose(); 957Interlocked.Exchange(ref _singleBufferSendEventArgs, null)?.Dispose(); 1033if (Interlocked.CompareExchange(ref cache, this, null) != null)
System\Net\Sockets\SocketAsyncContext.Unix.cs (9)
92Interlocked.Exchange(ref _cachedAcceptOperation, null) ?? 96Interlocked.Exchange(ref _cachedBufferMemoryReceiveOperation, null) ?? 100Interlocked.Exchange(ref _cachedBufferListReceiveOperation, null) ?? 104Interlocked.Exchange(ref _cachedBufferMemorySendOperation, null) ?? 108Interlocked.Exchange(ref _cachedBufferListSendOperation, null) ?? 157int oldState = Interlocked.CompareExchange(ref _state, (int)State.Running, (int)State.Waiting); 185if (state == Interlocked.CompareExchange(ref _state, newState, state)) 221if (state == Interlocked.CompareExchange(ref _state, newState, state)) 258Debug.Assert(Interlocked.CompareExchange(ref _callbackQueued, 1, 0) == 0, $"Unexpected _callbackQueued: {_callbackQueued}");
System\Net\Sockets\SocketAsyncEngine.Unix.cs (3)
102int engineIndex = Math.Abs(Interlocked.Increment(ref s_allocateFromEngine) % s_engines.Length); 211if (Interlocked.CompareExchange(ref _eventQueueProcessingRequested, 1, 0) == 0) 223Interlocked.Exchange(ref _eventQueueProcessingRequested, 0);
System\Net\Sockets\SocketAsyncEventArgs.cs (4)
472if (Interlocked.CompareExchange(ref _operating, Disposed, Free) != Free) 499int status = Interlocked.CompareExchange(ref _operating, Configuring, Free); 518int status = Interlocked.CompareExchange(ref _operating, InProgress, Free); 852public bool ReachedCoordinationPointFirst() => Interlocked.Exchange(ref _isCompleted, 1) == 0;
System\Net\Sockets\SocketsTelemetry.cs (15)
82Interlocked.Increment(ref _currentOutgoingConnectAttempts); 93long newCount = Interlocked.Decrement(ref _currentOutgoingConnectAttempts); 99Interlocked.Increment(ref _outgoingConnectionsEstablished); 133Interlocked.Increment(ref _incomingConnectionsEstablished); 147Interlocked.Add(ref _bytesReceived, count); 154Interlocked.Add(ref _bytesSent, count); 160Interlocked.Increment(ref _datagramsReceived); 166Interlocked.Increment(ref _datagramsSent); 175_currentOutgoingConnectAttemptsCounter ??= new PollingCounter("current-outgoing-connect-attempts", this, () => Interlocked.Read(ref _currentOutgoingConnectAttempts)) 179_outgoingConnectionsEstablishedCounter ??= new PollingCounter("outgoing-connections-established", this, () => Interlocked.Read(ref _outgoingConnectionsEstablished)) 183_incomingConnectionsEstablishedCounter ??= new PollingCounter("incoming-connections-established", this, () => Interlocked.Read(ref _incomingConnectionsEstablished)) 187_bytesReceivedCounter ??= new PollingCounter("bytes-received", this, () => Interlocked.Read(ref _bytesReceived)) 191_bytesSentCounter ??= new PollingCounter("bytes-sent", this, () => Interlocked.Read(ref _bytesSent)) 195_datagramsReceivedCounter ??= new PollingCounter("datagrams-received", this, () => Interlocked.Read(ref _datagramsReceived)) 199_datagramsSentCounter ??= new PollingCounter("datagrams-sent", this, () => Interlocked.Read(ref _datagramsSent))
System\Net\Sockets\TCPClient.cs (1)
255if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
System.Net.WebClient (5)
src\libraries\Common\src\System\Threading\Tasks\RendezvousAwaitable.cs (2)
106Action? c = _continuation ?? Interlocked.CompareExchange(ref _continuation, s_completionSentinel, null); 127Action? c = _continuation ?? Interlocked.CompareExchange(ref _continuation, continuation, null);
System\Net\WebClient.cs (3)
92if (Interlocked.Increment(ref _callNesting) > 1) 140private void EndOperation() => Interlocked.Decrement(ref _callNesting); 1183if (Interlocked.CompareExchange(ref _asyncOp, null, asyncOp) == asyncOp)
System.Net.WebProxy (1)
System\Net\WebProxy.NonBrowser.cs (1)
56if (Interlocked.Exchange(ref s_networkChangeRegistered, 1) != 0)
System.Net.WebSockets (3)
System\Net\WebSockets\AsyncMutex.cs (3)
59Interlocked.Decrement(ref _gate) >= 0 ? Task.CompletedTask : 140Interlocked.Increment(ref m._gate); 178if (Interlocked.Increment(ref _gate) < 1)
System.Net.WebSockets.Client (4)
System\Net\WebSockets\ClientWebSocket.cs (3)
108switch ((InternalState)Interlocked.CompareExchange(ref _state, (int)InternalState.Connecting, (int)InternalState.Created)) 138if ((InternalState)Interlocked.CompareExchange(ref _state, (int)InternalState.Connected, (int)InternalState.Connecting) != InternalState.Connecting) 195if ((InternalState)Interlocked.Exchange(ref _state, (int)InternalState.Disposed) != InternalState.Disposed)
System\Net\WebSockets\WebSocketHandle.Managed.cs (1)
268if (Interlocked.CompareExchange(ref invokerRef, invoker, null) is not null)
System.Private.CoreLib (213)
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.ThreadPoolValueTaskSource.cs (1)
23Interlocked.Exchange(ref _reusableThreadPoolValueTaskSource, null) ?? new ThreadPoolValueTaskSource(this);
src\libraries\System.Private.CoreLib\src\System\AppContext.cs (2)
64Interlocked.CompareExchange(ref s_dataStore, new Dictionary<string, object?>(), null); 135Interlocked.CompareExchange(ref s_switches, new Dictionary<string, bool>(), null);
src\libraries\System.Private.CoreLib\src\System\AppDomain.cs (2)
39Interlocked.CompareExchange(ref s_domain, new AppDomain(), null); 284if (Interlocked.CompareExchange(ref _defaultPrincipal, principal, null) is not null)
src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs (4)
44return Interlocked.CompareExchange(ref _buckets[bucketIndex], inst, null) ?? inst; 224if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer) 265if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer && 286if (Interlocked.Exchange(ref _trimCallbackCreated, 1) == 0)
src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueueSegment.cs (4)
102Interlocked.Add(ref _headAndTail.Tail, FreezeOffset); 135if (Interlocked.CompareExchange(ref _headAndTail.Head, currentHead + 1, currentHead) == currentHead) 202Interlocked.MemoryBarrier(); 293if (Interlocked.CompareExchange(ref _headAndTail.Tail, currentTail + 1, currentTail) == currentTail)
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.SerializationInfoTable.cs (1)
22Interlocked.CompareExchange(ref s_serializationInfoTable, new ConditionalWeakTable<object, SerializationInfo>(), null);
src\libraries\System.Private.CoreLib\src\System\ComAwareWeakReference.cs (1)
135if (Interlocked.CompareExchange(ref taggedHandle, newTaggedHandle, current) == current)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Debug.cs (1)
26return Interlocked.Exchange(ref s_provider, provider);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ActivityTracker.cs (4)
100id = Interlocked.Increment(ref m_nextId); 102id = Interlocked.Increment(ref currentActivity.m_lastChildID); 187if (Interlocked.CompareExchange(ref activityToStop.m_stopped, 1, 0) == 0) 388uint id = unchecked((uint)Interlocked.Increment(ref ancestor.m_lastChildID)); // Get a unique ID
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs (2)
154double result = Interlocked.CompareExchange(ref _bufferedValues[i], value, UnusedBufferSlotValue); 179double value = Interlocked.Exchange(ref _bufferedValues[i], UnusedBufferSlotValue);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (3)
2201Interlocked.CompareExchange(ref m_createEventLock, new object(), null); 2460Interlocked.CompareExchange(ref _traceLoggingEventTypes, tlet, null); 4414Interlocked.CompareExchange(ref s_EventSources, new List<WeakReference<EventSource>>(2), null);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\ConcurrentSet.cs (1)
107newItems = Interlocked.CompareExchange(ref this.items, newItems, oldItems)!;
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\NameInfo.cs (2)
27if (Interlocked.CompareExchange(ref lastIdentity, newIdentity, snapshot) == snapshot) 42this.identity = Interlocked.Increment(ref lastIdentity);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\SimpleEventTypes.cs (1)
32Interlocked.CompareExchange(ref instance, newInstance, null);
src\libraries\System.Private.CoreLib\src\System\Environment.cs (2)
173Interlocked.CompareExchange(ref s_processPath, GetProcessPath() ?? "", null); 196Interlocked.CompareExchange(ref s_osVersion, GetOSVersion(), null);
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureInfo.cs (10)
146Interlocked.CompareExchange(ref s_userDefaultCulture, GetUserDefaultCulture(), null); 152Interlocked.CompareExchange(ref s_userDefaultUICulture, GetUserDefaultUICulture(), null); 390Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null); 412Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null); 531Interlocked.CompareExchange<CultureInfo?>(ref _parent, culture, null); 727Interlocked.CompareExchange(ref _numInfo, temp, null); 753Interlocked.CompareExchange(ref _dateTimeInfo, temp, null); 858Interlocked.MemoryBarrier(); 1152cache = Interlocked.CompareExchange(ref s_cachedCulturesByName, cache, null) ?? cache; 1167cache = Interlocked.CompareExchange(ref s_cachedCulturesByLcid, cache, null) ?? cache;
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEnumerable.cs (1)
45return Interlocked.Exchange(ref _enumerator, null) ?? new DelegateEnumerator(this, isNormalized: false);
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEnumerator.Unix.cs (1)
86IntPtr handle = Interlocked.Exchange(ref _directoryHandle, IntPtr.Zero);
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\BufferedFileStreamStrategy.cs (1)
1037Interlocked.CompareExchange(ref _buffer, GC.AllocateUninitializedArray<byte>(_bufferSize), null);
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\OSFileStreamStrategy.cs (3)
82=> Interlocked.Add(ref _filePosition, actualBytesTransferred - expectedBytesTransferred); 259long writeOffset = CanSeek ? Interlocked.Add(ref _filePosition, source.Length) - source.Length : -1; 289long readOffset = Interlocked.Add(ref _filePosition, destination.Length) - destination.Length;
src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (1)
26Interlocked.CompareExchange(ref _asyncActiveSemaphore, new SemaphoreSlim(1, 1), null) ??
src\libraries\System.Private.CoreLib\src\System\Lazy.cs (1)
355LazyHelper? previous = Interlocked.CompareExchange(ref _state, LazyHelper.PublicationOnlyWaitForOtherThreadToPublish, publicationOnly);
src\libraries\System.Private.CoreLib\src\System\Reflection\ModifiedFunctionPointerType.cs (2)
30Interlocked.CompareExchange(ref _returnType, GetTypeParameter(UnmodifiedType.GetFunctionPointerReturnType(), 0), null); 46Interlocked.CompareExchange(ref _parameterTypes, parameterTypes, null);
src\libraries\System.Private.CoreLib\src\System\Reflection\ModifiedGenericType.cs (1)
30Interlocked.CompareExchange(ref _genericArguments, genericArguments, null);
src\libraries\System.Private.CoreLib\src\System\Reflection\ModifiedHasElementType.cs (1)
28Interlocked.CompareExchange(ref _elementType, GetTypeParameter(UnmodifiedType.GetElementType()!, 0), null);
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.Core.cs (2)
112Interlocked.CompareExchange(ref s_binaryFormatterType, binaryFormatterType, null); 113Interlocked.CompareExchange(ref s_deserializeMethod, deserializeMethod, null);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\CastCache.cs (3)
181Interlocked.ReadMemoryBarrier(); 310uint versionOrig = Interlocked.CompareExchange(ref pEntry._version, newVersion, version); 373uint versionOrig = Interlocked.CompareExchange(ref pEntry._version, newVersion, version);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (1)
318ConditionalWeakTable<TKey, TValue>? table = Interlocked.Exchange(ref _table, null);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (3)
165Interlocked.ReadMemoryBarrier(); 291uint versionOrig = Interlocked.CompareExchange(ref pEntry.Version, newVersion, version); 355uint versionOrig = Interlocked.CompareExchange(ref pEntry.Version, newVersion, version);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs (1)
312(box = Interlocked.Exchange<StateMachineBox<TStateMachine>?>(ref slot, null)) is null)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (1)
75IntPtr handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeLibrary.cs (1)
211Interlocked.CompareExchange(ref s_nativeDllResolveMap,
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (4)
117long count = Interlocked.Increment(ref s_safeHandlesFinalized); 130Interlocked.Or(ref _state, StateBits.Closed); 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\Runtime\Loader\AssemblyLoadContext.cs (3)
39Interlocked.CompareExchange(ref s_allContexts, new Dictionary<long, WeakReference<AssemblyLoadContext>>(), null) ?? 131Interlocked.Exchange(ref _unloading, null!)?.Invoke(this); 531Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext?>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext?>(), null);
src\libraries\System.Private.CoreLib\src\System\Runtime\MemoryFailPoint.cs (2)
97Interlocked.Add(ref s_hiddenLastKnownFreeAddressSpace, addend); 331Interlocked.Add(ref s_failPointReservedMemory, (long)size);
src\libraries\System.Private.CoreLib\src\System\Text\EncodingProvider.cs (2)
55Interlocked.CompareExchange(ref s_providers, new EncodingProvider[1] { provider }, null) is null) 73if (Interlocked.CompareExchange(ref s_providers, newProviders, providers) == providers)
src\libraries\System.Private.CoreLib\src\System\Text\EncodingTable.cs (2)
180Interlocked.CompareExchange<CodePageDataItem?[]?>(ref s_codePageToCodePageData, new CodePageDataItem[MappedCodePages.Length], null); 218Interlocked.CompareExchange<CodePageDataItem?>(ref s_codePageToCodePageData[index], InternalGetCodePageDataItem(codePage, index), null);
src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (10)
100if (Interlocked.CompareExchange(ref _kernelEvent, mre, null) != null) 444ITimer? currentTimer = Interlocked.CompareExchange(ref _timer, timer, null); 558ManualResetEvent? mre = Interlocked.Exchange<ManualResetEvent?>(ref _kernelEvent!, null); 605registrations = Interlocked.CompareExchange(ref _registrations, registrations, null) ?? registrations; 707Interlocked.CompareExchange(ref _state, NotifyingState, NotCanceledState) == NotCanceledState) 737Registrations? registrations = Interlocked.Exchange(ref _registrations, null); 740Interlocked.Exchange(ref _state, NotifyingCompleteState); 829Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0); // for safety, prevent reorderings crossing this point and seeing inconsistent state. 1167if (Interlocked.Exchange(ref value, 1) != 0) 1175do { sw.SpinOnce(); } while (Interlocked.Exchange(ref value, 1) == 1);
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 (4)
202return (IntPtr)Interlocked.Exchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value); 220return (UIntPtr)Interlocked.Exchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value); 392return (IntPtr)Interlocked.CompareExchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value, (long)comparand); 411return (UIntPtr)Interlocked.CompareExchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value, (long)comparand);
src\libraries\System.Private.CoreLib\src\System\Threading\LazyInitializer.cs (3)
63Interlocked.CompareExchange(ref target, Activator.CreateInstance<T>(), null!); 120Interlocked.CompareExchange(ref target, value, null!); 289Interlocked.CompareExchange(ref syncLock, new object(), null) ??
src\libraries\System.Private.CoreLib\src\System\Threading\Lock.cs (6)
489Interlocked.Increment(ref s_contentionCount); 615AutoResetEvent? waitEventBeforeUpdate = Interlocked.CompareExchange(ref _waitEvent, newWaitEvent, null); 846new State(Interlocked.CompareExchange(ref lockObj._state, toState._state, fromState._state)); 884var state = new State(Interlocked.Decrement(ref lockObj._state)); 1004var state = new State(Interlocked.Add(ref lockObj._state, Neg(SpinnerCountIncrement))); 1148var state = new State(Interlocked.Add(ref lockObj._state, Neg(IsWaiterSignaledToWakeMask)));
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelLifoSemaphore.cs (2)
319var countsAfterUpdate = new Counts(Interlocked.Add(ref _data, unchecked((ulong)-1) << WaiterCountShift)); 364new Counts(Interlocked.CompareExchange(ref _data, newCounts._data, oldCounts._data));
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelLock.cs (5)
118int state = Interlocked.CompareExchange(ref _state, LockedMask, 0); 135return (state & LockedMask) == 0 && Interlocked.CompareExchange(ref _state, state + LockedMask, state) == state; 168int state = Interlocked.Add(ref _state, WaiterCountIncrement); 176Interlocked.CompareExchange(ref _state, state + (LockedMask - WaiterCountIncrement), state) == state) 201if (Interlocked.Decrement(ref _state) != 0)
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelSpinWaiter.cs (2)
24int spinningThreadCount = Interlocked.Increment(ref _spinningThreadCount); 48Interlocked.Decrement(ref _spinningThreadCount);
src\libraries\System.Private.CoreLib\src\System\Threading\ManualResetEventSlim.cs (3)
208Interlocked.CompareExchange(ref m_lock, new object(), null); // failure is benign. Someone else set the value. 225if (Interlocked.CompareExchange(ref m_eventObj, newEventObj, null) != null) 682if (Interlocked.CompareExchange(ref m_combinedState, newState, oldState) == oldState)
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.cs (1)
464Interlocked.Increment(ref _separated.numRequestedWorkers);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.GateThread.cs (2)
167Interlocked.Decrement(ref threadPoolInstance._separated.gateThreadRunningState) <= GetRunningStateForNumRuns(0)) 214int numRunsMask = Interlocked.Exchange(ref threadPoolInstance._separated.gateThreadRunningState, GetRunningStateForNumRuns(MaxRuns));
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.ThreadCounts.cs (1)
114return new ThreadCounts(Interlocked.CompareExchange(ref _data, newCounts._data, oldCounts._data));
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.WorkerThread.cs (2)
111Interlocked.CompareExchange(ref threadPoolInstance._numThreadsBeingKeptAlive, count + 1, count); 366int prevCount = Interlocked.CompareExchange(ref threadPoolInstance._separated.numRequestedWorkers, count - 1, count);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.WorkerTracking.cs (1)
112Interlocked.CompareExchange(ref _data, newCounts._data, oldCounts._data));
src\libraries\System.Private.CoreLib\src\System\Threading\ReaderWriterLockSlim.cs (4)
141_lockID = Interlocked.Increment(ref s_nextLockID); 1538return Interlocked.CompareExchange(ref _isLocked, 1, 0) == 0; 1555Interlocked.Add(ref _enterDeprioritizationState, deprioritizationStateChange); 1584Interlocked.Add(ref _enterDeprioritizationState, -deprioritizationStateChange);
src\libraries\System.Private.CoreLib\src\System\Threading\RegisteredWaitHandle.Portable.cs (2)
75Interlocked.Exchange(ref s_cachedEvent, null) ?? 80if (Interlocked.CompareExchange(ref s_cachedEvent, resetEvent, null) != null)
src\libraries\System.Private.CoreLib\src\System\Threading\SpinLock.cs (6)
97int result = Interlocked.CompareExchange(ref location, value, comparand); 343turn = (Interlocked.Add(ref _owner, 2) & WAITERS_MASK) >> 1; 395if (Interlocked.CompareExchange(ref _owner, observedOwner - 2, observedOwner) == observedOwner) 465Interlocked.Decrement(ref _owner); 519Interlocked.Exchange(ref _owner, LOCK_UNOWNED); 523Interlocked.Decrement(ref _owner);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\ConcurrentExclusiveSchedulerPair.cs (1)
154Interlocked.CompareExchange(ref m_completionState, new CompletionState(), null);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Future.cs (2)
380Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.RanToCompletion); 478Interlocked.CompareExchange(ref s_Factory, new TaskFactory<TResult>(), null) ??
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Sources\ManualResetValueTaskSourceCore.cs (2)
165storedContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null); 220Interlocked.CompareExchange(ref _continuation, ManualResetValueTaskSourceCoreShared.s_sentinel, null);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (31)
191Interlocked.CompareExchange(ref s_currentActiveTasks, new Dictionary<int, Task>(), null) ?? 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); 753Interlocked.And(ref m_stateFlags, ~(int)TaskStateFlags.WaitCompletionNotification); 887Interlocked.Increment(ref props.m_completionCountdown); 899Interlocked.Decrement(ref props.m_completionCountdown); 968if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null) 1068if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null) 1170newId = Interlocked.Increment(ref s_taskIdCounter); 1197Interlocked.CompareExchange(ref m_taskId, newId, 0); 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) 2005Interlocked.Decrement(ref props.m_completionCountdown) == 0) // Reaching this sub clause means there may be remaining active children, 2092Interlocked.Exchange(ref m_stateFlags, m_stateFlags | completionState); 2166Interlocked.CompareExchange(ref props.m_exceptionalChildren, new List<Task>(), null); 2183if (Interlocked.Decrement(ref props!.m_completionCountdown) == 0) 2292int prevState = Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled); 3281Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled); 3426object? continuationObject = Interlocked.Exchange(ref m_continuationObject, s_taskCompletionSentinel); 4544oldValue = Interlocked.CompareExchange(ref m_continuationObject, list, expected); 4601if ((m_continuationObject != null) || (Interlocked.CompareExchange(ref m_continuationObject, tc, null) != null)) 4625continuationsLocalRef = Interlocked.CompareExchange(ref m_continuationObject, new List<object?>(), continuationObject); 5093if (Interlocked.Decrement(ref _count) == 0) Set(); 6046object? failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, completedTask, null); 6065failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, new List<Task> { first, completedTask }, first); 6079if (Interlocked.Decrement(ref _remainingToComplete) == 0) 6364if (Interlocked.Decrement(ref m_count) == 0) 6596if ((task1 = Interlocked.Exchange(ref _task1, null)) != null) 6845public bool TryStart() => Interlocked.Exchange(ref _enumerated, 1) == 0;
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskFactory.cs (3)
1571if (Interlocked.Decrement(ref _count) == 0) 1641if (Interlocked.Decrement(ref _count) == 0) 2297Interlocked.Exchange(ref _stateFlags, isSyncBlockingFlag | CompletedFlag) == isSyncBlockingFlag)
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskScheduler.cs (3)
288Interlocked.CompareExchange(ref s_activeTaskSchedulers, new ConditionalWeakTable<TaskScheduler, object?>(), null); 365newId = Interlocked.Increment(ref s_taskSchedulerIdCounter); 368Interlocked.CompareExchange(ref m_taskSchedulerId, newId, 0);
src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (3)
349Interlocked.CompareExchange(ref s_asyncLocalPrincipal, new AsyncLocal<IPrincipal?>(), null); 543public static void MemoryBarrier() => Interlocked.MemoryBarrier(); 657return Interlocked.CompareExchange(ref s_nameToSlotMap, nameToSlotMap, null) ?? nameToSlotMap;
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (11)
40if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues) 80if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues) 264Interlocked.Exchange(ref m_tailIndex, tail); 330Interlocked.Exchange(ref m_headIndex, head + 1); 577if (Interlocked.CompareExchange(ref _separated.hasOutstandingThreadRequest, 1, 0) == 0) 591Interlocked.MemoryBarrier(); 660Interlocked.CompareExchange(ref _mayHaveHighPriorityWorkItems, 0, 1) != 0 && 1092if (Interlocked.CompareExchange(ref _isScheduledForProcessing, 1, 0) == 0) 1107Interlocked.MemoryBarrier(); 1168Interlocked.MemoryBarrier(); // ensure that an old cached value is not read below 11790 == Interlocked.Exchange(ref executed, 1),
src\libraries\System.Private.CoreLib\src\System\Threading\Win32ThreadPoolNativeOverlapped.cs (5)
57if (Interlocked.CompareExchange(ref s_freeList, overlapped->_nextFree, freePtr) != freePtr) 70int dataIndex = Interlocked.Increment(ref s_dataCount) - 1; 93if (Interlocked.CompareExchange(ref s_dataArray, newDataArray, dataArray) != dataArray) 104Interlocked.Exchange(ref dataArray![dataIndex], data); 170if (Interlocked.CompareExchange(ref s_freeList, (IntPtr)overlapped, freePtr) == freePtr)
src\libraries\System.Private.CoreLib\src\System\TimeZone.cs (1)
26Interlocked.CompareExchange<object?>(ref s_InternalSyncObject, o, null);
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.cs (3)
155Interlocked.CompareExchange(ref _displayName, PopulateDisplayName(), null); 166Interlocked.CompareExchange(ref _standardDisplayName, PopulateStandardDisplayName(), null); 177Interlocked.CompareExchange(ref _daylightDisplayName, PopulateDaylightDisplayName(), null);
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.FullGlobalizationData.Unix.cs (1)
83Interlocked.CompareExchange(ref _uiCulture, uiCulture, null);
src\libraries\System.Private.CoreLib\src\System\Type.cs (1)
710Interlocked.CompareExchange(ref s_defaultBinder, new DefaultBinder(), null) ??
src\System\Diagnostics\StackFrameHelper.cs (1)
133Interlocked.CompareExchange(ref s_getSourceLineInfo, getSourceLineInfo, null);
src\System\MulticastDelegate.CoreCLR.cs (1)
147if (a[index] == null && Threading.Interlocked.CompareExchange<object?>(ref a[index], o, null) == null)
src\System\Reflection\RuntimeAssembly.cs (2)
61Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null); 170Interlocked.CompareExchange(ref m_fullname, s, null);
src\System\Runtime\InteropServices\ComWrappers.cs (3)
117private readonly long id = Interlocked.Increment(ref s_instanceCounter); 327if (null != Interlocked.CompareExchange(ref s_globalInstanceForTrackerSupport, instance, null)) 358if (null != Interlocked.CompareExchange(ref s_globalInstanceForMarshalling, instance, null))
src\System\RuntimeType.CoreCLR.cs (3)
1494existingCache = Interlocked.CompareExchange(ref m_cache, newCache, null); 1690Interlocked.CompareExchange(ref s_methodInstantiationsLock!, new object(), null); 2460IntPtr gcHandle = Interlocked.CompareExchange(ref m_cache, newgcHandle, IntPtr.Zero);
System.Private.DataContractSerialization (19)
System\Runtime\Serialization\ClassDataContract.cs (6)
93Interlocked.MemoryBarrier(); 206Interlocked.MemoryBarrier(); 240Interlocked.MemoryBarrier(); 955Interlocked.MemoryBarrier(); 1094Interlocked.MemoryBarrier(); 1219Interlocked.MemoryBarrier();
System\Runtime\Serialization\CollectionDataContract.cs (5)
223Interlocked.MemoryBarrier(); 290Interlocked.MemoryBarrier(); 324Interlocked.MemoryBarrier(); 369Interlocked.MemoryBarrier(); 705Interlocked.MemoryBarrier();
System\Runtime\Serialization\EnumDataContract.cs (1)
277Interlocked.MemoryBarrier();
System\Runtime\Serialization\Json\JsonClassDataContract.cs (2)
48Interlocked.MemoryBarrier(); 79Interlocked.MemoryBarrier();
System\Runtime\Serialization\Json\JsonCollectionDataContract.cs (3)
48Interlocked.MemoryBarrier(); 85Interlocked.MemoryBarrier(); 116Interlocked.MemoryBarrier();
System\Runtime\Serialization\XmlDataContract.cs (2)
107Interlocked.MemoryBarrier(); 195Interlocked.MemoryBarrier();
System.Private.Uri (6)
System\Uri.cs (4)
170Interlocked.CompareExchange(ref _moreInfo, new MoreInfo(), null); 207Interlocked.Or(ref Unsafe.As<Flags, ulong>(ref _flags), (ulong)flags); 2395Interlocked.CompareExchange(ref _info, info, null!); 2401ulong oldValue = Interlocked.CompareExchange(ref Unsafe.As<Flags, ulong>(ref _flags), (ulong)newValue, (ulong)current);
System\UriScheme.cs (1)
80ulong previous = Interlocked.Or(ref Unsafe.As<Uri.Flags, ulong>(ref uri._flags), (ulong)Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
System\UriSyntax.cs (1)
272Interlocked.Or(ref Unsafe.As<Uri.Flags, ulong>(ref thisUri._flags), (ulong)Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
System.Private.Xml (8)
System\Xml\Schema\Preprocessor.cs (1)
470Interlocked.CompareExchange<XmlSchema?>(ref s_builtInSchemaForXmlNS, tempSchema, null);
System\Xml\Schema\XmlSchema.cs (1)
393_schemaId = Interlocked.Increment(ref s_globalIdCounter);
System\Xml\Schema\XmlSchemaSet.cs (1)
67Interlocked.CompareExchange<object?>(ref _internalSyncObject, o, null);
System\Xml\Schema\XmlSchemaValidator.cs (4)
2468Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiTypeSO, tempXsiTypeSO, null); 2476Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiNilSO, tempxsiNilSO, null); 2485Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiSLSO, tempxsiSLSO, null); 2494Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiNoNsSLSO, tempxsiNoNsSLSO, null);
System\Xml\Xsl\IlGen\XmlILModule.cs (1)
277System.Threading.Interlocked.Increment(ref s_assemblyId);
System.Private.Xml.Linq (12)
System\Xml\Linq\XContainer.cs (2)
10using Interlocked = System.Threading.Interlocked; 78Interlocked.CompareExchange<object>(ref content, t, s);
System\Xml\Linq\XHashtable.cs (6)
8using Interlocked = System.Threading.Interlocked; 179entryIdx = Interlocked.CompareExchange(ref _buckets[bucketIdx], FullList, EndOfList); 192entryIdx = Interlocked.CompareExchange(ref _entries[entryIdx].Next, FullList, EndOfList); 286newEntry = Interlocked.Increment(ref _numEntries); 304entryIndex = Interlocked.CompareExchange(ref _buckets[hashCode & (_buckets.Length - 1)], newEntry, EndOfList); 306entryIndex = Interlocked.CompareExchange(ref _entries[entryIndex].Next, newEntry, EndOfList);
System\Xml\Linq\XNamespace.cs (3)
6using Interlocked = System.Threading.Interlocked; 242Interlocked.CompareExchange(ref s_namespaces, new XHashtable<WeakReference<XNamespace>>(ExtractNamespace, NamespacesCapacity), null); 310Interlocked.CompareExchange(ref refNmsp, new WeakReference<XNamespace>(new XNamespace(namespaceName)), refOld);
System\Xml\XPath\XNodeNavigator.cs (1)
843System.Threading.Interlocked.CompareExchange(ref s_XmlNamespaceDeclaration, new XAttribute(XNamespace.Xmlns.GetName("xml"), xmlPrefixNamespace), null);
System.Reflection.DispatchProxy (1)
System\Reflection\DispatchProxyGenerator.cs (1)
223int nextId = Interlocked.Increment(ref _typeId);
System.Reflection.Metadata (18)
System\Reflection\Internal\MemoryBlocks\ByteArrayMemoryProvider.cs (2)
26Interlocked.Exchange(ref _pinned, null)?.Dispose(); 51if (Interlocked.CompareExchange(ref _pinned, newPinned, null) != null)
System\Reflection\Internal\MemoryBlocks\MemoryMappedFileBlock.cs (2)
50Interlocked.Exchange(ref _safeBuffer, null)?.ReleasePointer(); 51Interlocked.Exchange(ref _accessor, null)?.Dispose();
System\Reflection\Internal\MemoryBlocks\NativeHeapMemoryBlock.cs (1)
46IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero);
System\Reflection\Internal\MemoryBlocks\StreamMemoryBlockProvider.cs (3)
54Interlocked.Exchange(ref _stream, null!)?.Dispose(); 57Interlocked.Exchange(ref _lazyMemoryMap, null)?.Dispose(); 158if (Interlocked.CompareExchange(ref _lazyMemoryMap, newMemoryMap, null) != null)
System\Reflection\Internal\Utilities\ObjectPool`1.cs (1)
78if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
System\Reflection\Internal\Utilities\PinnedObject.cs (1)
43if (Interlocked.Exchange(ref _isValid, 0) != 0)
System\Reflection\Metadata\Internal\VirtualHeap.cs (2)
56var blobs = Interlocked.Exchange(ref _blobs, null); 115Interlocked.CompareExchange(ref lazyHeap, new VirtualHeap(), null);
System\Reflection\Metadata\MetadataReaderProvider.cs (1)
289if (Interlocked.CompareExchange(ref _lazyMetadataBlock, newBlock, null) != null)
System\Reflection\PortableExecutable\PEReader.cs (5)
327Interlocked.CompareExchange(ref _lazyPEHeaders, headers, null); 347if (Interlocked.CompareExchange(ref _lazyImageBlock, newBlock, null) != null) 369if (Interlocked.CompareExchange(ref _lazyMetadataBlock, newBlock, null) != null) 389Interlocked.CompareExchange(ref _lazyPESectionBlocks, new AbstractMemoryBlock[PEHeaders.SectionHeaders.Length], null); 423if (Interlocked.CompareExchange(ref _lazyPESectionBlocks[index], newBlock, null) != null)
System.Reflection.MetadataLoadContext (7)
System\Reflection\TypeLoading\Assemblies\RoAssembly.Modules.cs (2)
85return Interlocked.CompareExchange(ref _loadedModules[loadedModulesIndex], newModule, null) ?? newModule; 114Interlocked.CompareExchange(ref _loadedModules[loadedModuleIndex], newModule, null);
System\Reflection\TypeLoading\General\Ecma\MetadataTable.cs (1)
40return Interlocked.CompareExchange(ref table[index], newValue, null) ?? newValue;
System\Reflection\TypeLoading\Modules\Ecma\EcmaModule.MetadataTables.cs (4)
20Interlocked.CompareExchange(ref _lazyTypeDefTable, CreateTable<EcmaDefinitionType>(TableIndex.TypeDef), null) ?? 44Interlocked.CompareExchange(ref _lazyTypeRefTable, CreateTable<RoDefinitionType>(TableIndex.TypeRef), null) ?? 55Interlocked.CompareExchange(ref _lazyGenericParamTable, CreateTable<EcmaGenericParameterType>(TableIndex.GenericParam), null) ?? 66Interlocked.CompareExchange(ref _lazyAssemblyRefTable, CreateTable<RoAssembly>(TableIndex.AssemblyRef), null) ??
System.Runtime.Caching (28)
System\Runtime\Caching\CacheExpires.cs (3)
799if (Interlocked.Exchange(ref _inFlush, 1) == 0) 821Interlocked.Exchange(ref _inFlush, 0); 874if (timerHandleRef != null && Interlocked.CompareExchange(ref _timerHandleRef, null, timerHandleRef) == timerHandleRef)
System\Runtime\Caching\CacheMemoryMonitor.cs (4)
126Interlocked.Exchange(ref s_autoPrivateBytesLimit, memoryLimit); 136if (sref != null && Interlocked.CompareExchange(ref _sizedRefMultiple, null, sref) == sref) 151Interlocked.Exchange(ref s_effectiveProcessMemoryLimit, memoryLimit); 261Interlocked.CompareExchange(ref s_memoryCacheManager, memoryCacheManager, null);
System\Runtime\Caching\CacheUsage.cs (2)
877if (Interlocked.Exchange(ref _inFlush, 1) == 0) 902Interlocked.Exchange(ref _inFlush, 0);
System\Runtime\Caching\ChangeMonitor.cs (2)
115Interlocked.CompareExchange(ref _onChangedState, state, s_NOT_SET); 229if (Interlocked.CompareExchange(ref _onChangedCallback, onChangedCallback, null) != null)
System\Runtime\Caching\Counters.cs (4)
80if (counters != null && Interlocked.CompareExchange(ref _counters, null, counters) == counters) 92Interlocked.Increment(ref _counterValues[idx]); 97Interlocked.Add(ref _counterValues[idx], value); 102Interlocked.Decrement(ref _counterValues[idx]);
System\Runtime\Caching\HostFileChangeMonitor.cs (1)
111Interlocked.CompareExchange(ref s_fcn, fcn, null);
System\Runtime\Caching\MemoryCache.cs (1)
472if (Interlocked.Exchange(ref _disposed, 1) == 0)
System\Runtime\Caching\MemoryCacheEntry.cs (1)
205return (Interlocked.CompareExchange(ref _state, (int)value, (int)comparand) == (int)comparand);
System\Runtime\Caching\MemoryCacheStatistics.cs (6)
270if (Interlocked.Exchange(ref _inCacheManagerThread, 1) != 0) 330Interlocked.Exchange(ref _inCacheManagerThread, 0); 336if (Interlocked.Exchange(ref _disposed, 1) == 0) 341if (timerHandleRef != null && Interlocked.CompareExchange(ref _timerHandleRef, null, timerHandleRef) == timerHandleRef) 384while (Interlocked.Exchange(ref _inCacheManagerThread, 1) != 0) 405Interlocked.Exchange(ref _inCacheManagerThread, 0);
System\Runtime\Caching\MemoryCacheStore.cs (1)
253if (Interlocked.Exchange(ref _disposed, 1) == 0)
System\Runtime\Caching\ObjectCache.cs (1)
36if (Interlocked.CompareExchange(ref s_host, value, null) != null)
System\Runtime\Caching\SafeBitVector32.cs (2)
39int result = Interlocked.CompareExchange(ref _data, newData, oldData); 68int result = Interlocked.CompareExchange(ref _data, newData, oldData);
System.Runtime.InteropServices (3)
System\Runtime\InteropServices\HandleCollector.cs (2)
57Interlocked.Increment(ref _handleCount); 93Interlocked.Decrement(ref _handleCount);
System\Runtime\InteropServices\Marshalling\ComObject.cs (1)
84if (UniqueInstance && Interlocked.CompareExchange(ref _released, 1, 0) == 0)
System.Runtime.Serialization.Formatters (1)
System\Runtime\Serialization\Formatters\Binary\BinaryObjectInfo.cs (1)
739roi._objectInfoId = Interlocked.Increment(ref _readObjectInfoCounter);
System.Security.Cryptography (10)
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeHandleCache.cs (1)
29T? currentHandle = Interlocked.CompareExchange(ref s_invalidHandle, newHandle, null);
src\libraries\Common\src\System\Security\Cryptography\SP800108HmacCounterKdfImplementationManaged.cs (3)
64if (Interlocked.Exchange(ref _disposed, 1) == 0) 84if (Interlocked.CompareExchange(ref _keyReferenceCount, incrementedCount, current) == current) 93int newReferenceCount = Interlocked.Decrement(ref _keyReferenceCount);
System\Security\Cryptography\ConcurrencyBlock.cs (3)
14int count = Interlocked.Increment(ref block._count); 18Interlocked.Decrement(ref block._count); 36Interlocked.Decrement(ref _parentCount);
System\Security\Cryptography\X509Certificates\CertCollectionLoader.cs (1)
30List<ICertificatePal>? localCerts = Interlocked.Exchange(ref _certs, null);
System\Security\Cryptography\X509Certificates\OpenSslSingleCertLoader.cs (1)
28ICertificatePal? localCert = Interlocked.Exchange(ref _cert, null);
System\Security\Cryptography\X509Certificates\UnixPkcs12Reader.cs (1)
848byte[]? rented = Interlocked.Exchange(ref _rented, null);
System.Text.Encoding.CodePages (4)
System\Text\DBCSCodePageEncoding.cs (1)
236Interlocked.CompareExchange<object?>(ref s_InternalSyncObject, o, null);
System\Text\DecoderBestFitFallback.cs (1)
58Interlocked.CompareExchange<object?>(ref s_InternalSyncObject, o, null);
System\Text\EncoderBestFitFallback.cs (1)
58Interlocked.CompareExchange<object?>(ref s_InternalSyncObject, o, null);
System\Text\SBCSCodePageEncoding.cs (1)
140Interlocked.CompareExchange<object?>(ref s_InternalSyncObject, o, null);
System.Text.Json (16)
System\Text\Json\Document\JsonDocument.cs (2)
74byte[]? extraRentedBytes = Interlocked.Exchange<byte[]?>(ref _extraRentedArrayPoolBytes, null); 86PooledByteBufferWriter? extraBufferWriter = Interlocked.Exchange<PooledByteBufferWriter?>(ref _extraPooledByteBufferWriter, null);
System\Text\Json\Document\JsonDocument.MetadataDb.cs (1)
153byte[]? data = Interlocked.Exchange(ref _data, null!);
System\Text\Json\Nodes\JsonArray.cs (2)
322Interlocked.MemoryBarrier(); 339Interlocked.MemoryBarrier();
System\Text\Json\Nodes\JsonObject.IDictionary.cs (2)
220Interlocked.MemoryBarrier(); 240Interlocked.MemoryBarrier();
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (1)
33return Interlocked.CompareExchange(ref _cachingContext, ctx, null) ?? ctx;
System\Text\Json\Serialization\JsonSerializerOptions.cs (1)
1081return Interlocked.CompareExchange(ref location, options, null) ?? options;
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.cs (1)
139return Interlocked.CompareExchange(ref s_defaultInstance, newInstance, comparand: null) ?? newInstance;
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.Helpers.cs (1)
36return Interlocked.CompareExchange(ref s_memberAccessor, value, null) ?? value;
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
197return Interlocked.CompareExchange(ref _attributeProvider, provider, null) ?? provider;
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (1)
235JsonPropertyInfoList? result = Interlocked.CompareExchange(ref _properties, list, null);
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.WriteHelpers.cs (2)
340if (Interlocked.Increment(ref _serializationCount) == MinSerializationsSampleSize) 344Interlocked.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 (14)
System\Text\RegularExpressions\Regex.cs (4)
400Interlocked.CompareExchange(ref _replref, new WeakReference<RegexReplacement?>(null), null) ?? 424RegexRunner runner = Interlocked.Exchange(ref _runner, null) ?? CreateRunner(); 469RegexRunner runner = Interlocked.Exchange(ref _runner, null) ?? CreateRunner(); 532RegexRunner runner = Interlocked.Exchange(ref _runner, null) ?? CreateRunner();
System\Text\RegularExpressions\RegexAssemblyCompiler.cs (1)
52string typenumString = ((uint)Interlocked.Increment(ref s_typeCount)).ToString();
System\Text\RegularExpressions\RegexCharClass.cs (2)
1306uint[]? cache = asciiLazyCache ?? Interlocked.CompareExchange(ref asciiLazyCache, new uint[CacheArrayLength], null) ?? asciiLazyCache; 1308Interlocked
System\Text\RegularExpressions\RegexLWCGCompiler.cs (1)
47uint regexNum = (uint)Interlocked.Increment(ref s_regexCount);
System\Text\RegularExpressions\Symbolic\CharSetSolver.cs (2)
44Interlocked.CompareExchange(ref s_nonAscii, CreateBDDFromRange('\x80', '\uFFFF'), null) ?? 56Interlocked.CompareExchange(ref ascii[c], CreateBdd(c), null) ??
System\Text\RegularExpressions\Symbolic\UnicodeCategoryConditions.cs (4)
37Interlocked.CompareExchange(ref s_categories[(int)category], BDD.Deserialize(UnicodeCategoryRanges.GetSerializedCategory(category)), null) ?? 43Interlocked.CompareExchange(ref s_whiteSpace, BDD.Deserialize(UnicodeCategoryRanges.SerializedWhitespaceBDD), null) ?? 50Interlocked.CompareExchange(ref s_wordLetter, 72Interlocked.CompareExchange(ref s_wordLetterForAnchors, solver.Or(WordLetter(solver), solver.CreateBDDFromRange('\u200C', '\u200D')), null) ??
System.Text.RegularExpressions.Generator (2)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexCharClass.cs (1)
1306uint[]? cache = asciiLazyCache ?? Interlocked.CompareExchange(ref asciiLazyCache, new uint[CacheArrayLength], null) ?? asciiLazyCache;
Stubs.cs (1)
92uint oldValue = (uint)Interlocked.CompareExchange(ref Unsafe.As<uint, int>(ref location1), (int)newValue, (int)current);
System.Threading (26)
artifacts\obj\System.Threading\Debug\net9.0\System.Threading.Forwards.cs (1)
12[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Interlocked))]
System\Threading\Barrier.cs (1)
270return Interlocked.CompareExchange(ref _currentTotalCount, newCurrentTotal, currentTotal) == currentTotal;
System\Threading\CountdownEvent.cs (3)
183int newCount = Interlocked.Decrement(ref _currentCount); 233if (Interlocked.CompareExchange(ref _currentCount, observedCount - signalCount, observedCount) == observedCount) 340if (Interlocked.CompareExchange(ref _currentCount, observedCount + signalCount, observedCount) == observedCount)
System\Threading\ReaderWriterLock.cs (21)
49_lockID = Interlocked.Increment(ref s_mostRecentLockID); 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); 215knownState = Interlocked.Add(ref _state, modifyState) - modifyState; 241Interlocked.Add(ref _state, LockStates.Reader - LockStates.ReaderSignaled); 264Interlocked.Add(ref _state, -LockStates.ReaderSignaled); 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); 380knownState = Interlocked.Add(ref _state, modifyState) - modifyState; 407knownState = Interlocked.Add(ref _state, modifyState) - modifyState; 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) 1026ManualResetEventSlim? previousEvent = Interlocked.CompareExchange(ref _readerEvent, currentEvent, null); 1047AutoResetEvent? previousEvent = Interlocked.CompareExchange(ref _writerEvent, currentEvent, null); 1099Interlocked.Add(ref _state, -LockStates.CachingEvents);
System.Threading.Channels (4)
System\Threading\Channels\AsyncOperation.cs (4)
185if (ReferenceEquals(Interlocked.CompareExchange(ref _continuation, null, s_availableSentinel), s_availableSentinel)) 254Action<object?>? prevContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null); 378Interlocked.CompareExchange(ref _completionReserved, 1, 0) == 0; 383if (_continuation != null || Interlocked.CompareExchange(ref _continuation, s_completedSentinel, null) != null)
System.Threading.RateLimiting (51)
System\Threading\RateLimiting\ConcurrencyLimiter.cs (11)
75TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 76TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 96Interlocked.Increment(ref _successfulLeasesCount); 99Interlocked.Increment(ref _failedLeasesCount); 115Interlocked.Increment(ref _failedLeasesCount); 131Interlocked.Increment(ref _successfulLeasesCount); 173Interlocked.Increment(ref _failedLeasesCount); 181Interlocked.Increment(ref _failedLeasesCount); 205Interlocked.Increment(ref _successfulLeasesCount); 218Interlocked.Increment(ref _successfulLeasesCount); 305Interlocked.Increment(ref _successfulLeasesCount);
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (11)
94TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 95TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 116Interlocked.Increment(ref _successfulLeasesCount); 120Interlocked.Increment(ref _failedLeasesCount); 131Interlocked.Increment(ref _failedLeasesCount); 150Interlocked.Increment(ref _successfulLeasesCount); 190Interlocked.Increment(ref _failedLeasesCount); 198Interlocked.Increment(ref _failedLeasesCount); 231Interlocked.Increment(ref _successfulLeasesCount); 244Interlocked.Increment(ref _successfulLeasesCount); 359Interlocked.Increment(ref _successfulLeasesCount);
System\Threading\RateLimiting\NoopLimiter.cs (3)
26TotalSuccessfulLeases = Interlocked.Read(ref _totalSuccessfulLeases) 32Interlocked.Increment(ref _totalSuccessfulLeases); 38Interlocked.Increment(ref _totalSuccessfulLeases);
System\Threading\RateLimiting\SlidingWindowRateLimiter.cs (11)
108TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 109TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 127Interlocked.Increment(ref _successfulLeasesCount); 131Interlocked.Increment(ref _failedLeasesCount); 143Interlocked.Increment(ref _failedLeasesCount); 162Interlocked.Increment(ref _successfulLeasesCount); 202Interlocked.Increment(ref _failedLeasesCount); 210Interlocked.Increment(ref _failedLeasesCount); 234Interlocked.Increment(ref _successfulLeasesCount); 248Interlocked.Increment(ref _successfulLeasesCount); 372Interlocked.Increment(ref _successfulLeasesCount);
System\Threading\RateLimiting\TimerAwaitable.cs (2)
89Action? continuation = Interlocked.Exchange(ref _callback, _callbackCompleted); 96ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted))
System\Threading\RateLimiting\TokenBucketRateLimiter.cs (11)
102TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 103TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 121Interlocked.Increment(ref _successfulLeasesCount); 125Interlocked.Increment(ref _failedLeasesCount); 136Interlocked.Increment(ref _failedLeasesCount); 155Interlocked.Increment(ref _successfulLeasesCount); 195Interlocked.Increment(ref _failedLeasesCount); 203Interlocked.Increment(ref _failedLeasesCount); 238Interlocked.Increment(ref _successfulLeasesCount); 251Interlocked.Increment(ref _successfulLeasesCount); 373Interlocked.Increment(ref _successfulLeasesCount);
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 (18)
Base\DataflowBlock.cs (7)
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) 1119IDisposable? disposableUnlink = Interlocked.CompareExchange<IDisposable?>(ref target._unlink, null, unlink); 1270IDisposable? disposableUnlink = Interlocked.CompareExchange(ref _unlink, null, unlink); 1536if (cachedUnlinker != null && Interlocked.CompareExchange(ref _unlinker, null, cachedUnlinker) == cachedUnlinker)
Blocks\WriteOnceBlock.cs (2)
193if (Interlocked.CompareExchange(ref _lazyCompletionTaskSource, Common.CompletedVoidResultTaskCompletionSource, null) != null) 502Interlocked.CompareExchange(ref _lazyCompletionTaskSource, new TaskCompletionSource<VoidResult>(TaskCreationOptions.RunContinuationsAsynchronously), null);
Internal\ActionOnDispose.cs (2)
90Interlocked.CompareExchange(ref _action, null, toRun) == toRun) 132Interlocked.CompareExchange(ref _action, null, toRun) == toRun)
Internal\SourceCore.cs (3)
395Interlocked.MemoryBarrier(); // ensure the read of _taskForOutputProcessing doesn't move up before the writes in Enqueue 450Interlocked.MemoryBarrier(); // ensure the read of _taskForOutputProcessing doesn't move up before the writes in Enqueue 861Interlocked.MemoryBarrier(); // synchronize with AddMessage(s) and its read of _taskForOutputProcessing
Internal\SpscTargetCore.cs (4)
94Interlocked.MemoryBarrier(); // ensure the read of _activeConsumer doesn't move up before the writes in Enqueue 150Interlocked.MemoryBarrier(); // ensure the read of _activeConsumer doesn't move up before the writes in Enqueue 169if (Interlocked.CompareExchange(ref _activeConsumer, newConsumer, null) == null) 255Task? previousConsumer = Interlocked.Exchange<Task?>(ref _activeConsumer, null);
System.Threading.Tasks.Parallel (19)
System\Threading\Tasks\Parallel.cs (5)
220forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID); 270int myIndex = Interlocked.Increment(ref actionIndex); // = index to use + 1 290myIndex = Interlocked.Increment(ref actionIndex); 972forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID); 2539forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
System\Threading\Tasks\Parallel.ForEachAsync.cs (6)
112sizeof(T) == sizeof(byte) ? Interlocked.CompareExchange(ref Unsafe.As<T, byte>(ref location), Unsafe.As<T, byte>(ref value), Unsafe.As<T, byte>(ref comparand)) == Unsafe.As<T, byte>(ref comparand) : 113sizeof(T) == sizeof(ushort) ? Interlocked.CompareExchange(ref Unsafe.As<T, ushort>(ref location), Unsafe.As<T, ushort>(ref value), Unsafe.As<T, ushort>(ref comparand)) == Unsafe.As<T, ushort>(ref comparand) : 114sizeof(T) == sizeof(uint) ? Interlocked.CompareExchange(ref Unsafe.As<T, uint>(ref location), Unsafe.As<T, uint>(ref value), Unsafe.As<T, uint>(ref comparand)) == Unsafe.As<T, uint>(ref comparand) : 115sizeof(T) == sizeof(ulong) ? Interlocked.CompareExchange(ref Unsafe.As<T, ulong>(ref location), Unsafe.As<T, ulong>(ref value), Unsafe.As<T, ulong>(ref comparand)) == Unsafe.As<T, ulong>(ref comparand) : 595Interlocked.Increment(ref _completionRefCount); 612public bool SignalWorkerCompletedIterating() => Interlocked.Decrement(ref _completionRefCount) == 0;
System\Threading\Tasks\ParallelLoopState.cs (3)
215Interlocked.CompareExchange(ref Unsafe.As<TInt, int>(ref pflags._lowestBreakIteration), Unsafe.As<TInt, int>(ref iteration), Unsafe.As<TInt, int>(ref oldLBI)) != Unsafe.As<TInt, int>(ref oldLBI) : 216Interlocked.CompareExchange(ref Unsafe.As<TInt, long>(ref pflags._lowestBreakIteration), Unsafe.As<TInt, long>(ref iteration), Unsafe.As<TInt, long>(ref oldLBI)) != Unsafe.As<TInt, long>(ref oldLBI)) 320if (Interlocked.CompareExchange(ref _loopStateFlags, oldState | newState, oldState) == oldState)
System\Threading\Tasks\ParallelRangeManager.cs (5)
109Interlocked.CompareExchange(ref _indexRanges[_nCurrentIndexRange]._nSharedCurrentIndexOffset, new StrongBox<long>(0), null); 123nMyOffset = Interlocked.Add(ref *(int*)indexPtr, (int)_nIncrementValue) - _nIncrementValue; 129nMyOffset = Interlocked.Add(ref sharedCurrentIndexOffset.Value, _nIncrementValue) - _nIncrementValue; 160Interlocked.Exchange(ref _indexRanges[_nCurrentIndexRange]._bRangeFinished, 1); 293int nInitialRange = (Interlocked.Increment(ref _nCurrentIndexRangeToAssign) - 1) % _indexRanges.Length;
System.Transactions.Local (29)
System\Transactions\CommittableTransaction.cs (2)
128if (Interlocked.Exchange(ref _disposed, Transaction._disposedTrueValue) == Transaction._disposedTrueValue) 144long remainingITx = Interlocked.Decrement(ref _internalTransaction._cloneCount);
System\Transactions\Enlistment.cs (2)
211string.Create(CultureInfo.InvariantCulture, $"{InternalTransaction.InstanceIdentifier}{Interlocked.Increment(ref InternalTransaction._nextHash)}"), 215Interlocked.MemoryBarrier();
System\Transactions\Transaction.cs (5)
269_cloneId = Interlocked.Increment(ref _internalTransaction._cloneCount); 283_cloneId = Interlocked.Increment(ref _internalTransaction._cloneCount); 778Interlocked.MemoryBarrier(); 828if (Interlocked.Exchange(ref _disposed, Transaction._disposedTrueValue) == Transaction._disposedTrueValue) 834long remainingITx = Interlocked.Decrement(ref _internalTransaction._cloneCount);
System\Transactions\TransactionManager.cs (7)
305if (Interlocked.Read(ref s_defaultTimeoutTicks) != DefaultSettingsSection.Timeout.Ticks) 318return new TimeSpan(Interlocked.Read(ref s_defaultTimeoutTicks)); 328Interlocked.Exchange(ref s_defaultTimeoutTicks, ValidateTimeout(value).Ticks); 329if (Interlocked.Read(ref s_defaultTimeoutTicks) != value.Ticks) 382long defaultTimeoutTicks = Interlocked.Read(ref s_defaultTimeoutTicks); 383Interlocked.Exchange(ref s_defaultTimeoutTicks, ValidateTimeout(new TimeSpan(defaultTimeoutTicks)).Ticks); 384if (Interlocked.Read(ref s_defaultTimeoutTicks) != defaultTimeoutTicks)
System\Transactions\TransactionTable.cs (12)
33Interlocked.CompareExchange(ref _syncRoot, new object(), null); 47Interlocked.CompareExchange(ref _writerFinishedEvent, new ManualResetEvent(true), null); 63readerIndex = Interlocked.Increment(ref _readersIn); 70Interlocked.Decrement(ref _readersIn); 103Interlocked.Increment(ref _readersOut); 305WeakReference? oldNextSetWeak = (WeakReference?)Interlocked.CompareExchange( 334WeakReference? oldNextSetWeak = (WeakReference?)Interlocked.CompareExchange( 502(WeakReference?)Interlocked.CompareExchange(ref lastBucketSet.nextSetWeak, null, nextWeakSet); 620int currentIndex = Interlocked.Increment(ref _index); 625Interlocked.MemoryBarrier(); // This data must be written before the transaction 642Bucket oldBucket = Interlocked.CompareExchange(ref _owningSet.headBucket, newBucket, this); 667Interlocked.MemoryBarrier();
System\Transactions\VolatileEnlistmentMultiplexing.cs (1)
69Interlocked.CompareExchange(ref s_classSyncObject, o, null);
System.Xaml (19)
System\Xaml\Schema\Reflector.cs (1)
374updated = oldValue == Interlocked.CompareExchange(ref flags, newValue, oldValue);
System\Xaml\Schema\TypeBits.cs (1)
97Interlocked.CompareExchange(ref _value, newValue, null);
System\Xaml\Schema\TypeReflector.cs (4)
174Interlocked.CompareExchange(ref _attachableMemberCache, 245Interlocked.CompareExchange(ref _nonAttachableMemberCache, 298Interlocked.CompareExchange(ref _positionalParameterTypes, 369Interlocked.CompareExchange(ref _aliasedProperties, dict, null);
System\Xaml\Schema\XamlValueConverter.cs (1)
48Interlocked.CompareExchange(ref _instance, CreateInstance(), null);
System\Xaml\XamlMember.cs (1)
859Interlocked.CompareExchange(ref _reflector, reflector, null);
System\Xaml\XamlSchemaContext.cs (10)
361Interlocked.CompareExchange(ref _xmlNsCompatDict, CreateDictionary<string, string>(), null); 486Interlocked.CompareExchange(ref _masterBracketCharacterCache, CreateDictionary<XamlType, Dictionary<string, SpecialBracketCharacters>>(), null); 497Interlocked.CompareExchange(ref _masterTypeList, CreateDictionary<Type, XamlType>(ReferenceEqualityComparer.Instance), null); 508Interlocked.CompareExchange(ref _masterValueConverterList, CreateDictionary<ReferenceEqualityTuple<Type, XamlType, Type>, object>(), null); 519Interlocked.CompareExchange(ref _masterMemberList, CreateDictionary<ReferenceEqualityTuple<MemberInfo, MemberInfo>, XamlMember>(), null); 708Interlocked.CompareExchange(ref _xmlnsInfo, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null); 719Interlocked.CompareExchange(ref _xmlnsInfoForDynamicAssemblies, CreateDictionary<WeakRefKey, XmlNsInfo>(), null); 731Interlocked.CompareExchange(ref _namespaceByUriList, CreateDictionary<string, XamlNamespace>(), null); 746Interlocked.CompareExchange(ref _xmlnsInfoForUnreferencedAssemblies, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null); 1242Interlocked.CompareExchange(ref _referenceAssemblyNames, asmNames, null);
System\Xaml\XamlType.cs (1)
1397Interlocked.CompareExchange(ref _reflector, reflector, null);
WasmAppBuilder (1)
EmccCompile.cs (1)
228int count = Interlocked.Increment(ref _numCompiled);