2601 references to Interlocked
AnalyzerRunner (1)
AnalyzerRunnerMefHostServices.cs (1)
24Interlocked.CompareExchange(ref s_defaultServices, MefHostServices.Create(DefaultAssemblies), null);
Aspire.Dashboard (8)
Components\Controls\Chart\PlotlyChart.razor.cs (1)
33public string ChartDivId { get; } = $"plotly-chart-container-{Interlocked.Increment(ref s_nextChartId)}";
Components\Pages\ConsoleLogs.razor.cs (1)
33private readonly int _subscriptionId = Interlocked.Increment(ref s_subscriptionId);
Otlp\Model\MetricValues\DimensionScope.cs (2)
45Interlocked.Increment(ref lastLongValue.Count); 65Interlocked.Increment(ref lastDoubleValue.Count);
Otlp\Storage\Subscription.cs (1)
21private readonly int _subscriptionId = Interlocked.Increment(ref s_subscriptionId);
ResourceService\DashboardClient.cs (2)
225var priorState = Interlocked.CompareExchange(ref _state, value: StateInitialized, comparand: StateNone); 563if (Interlocked.Exchange(ref _state, StateDisposed) is not StateDisposed)
Utils\CancellationSeries.cs (1)
60using var priorCts = Interlocked.Exchange(ref _cts, next);
Aspire.Hosting.Analyzers (1)
Infrastructure\WellKnownTypes.cs (1)
77Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null);
Aspire.Hosting.Tests (13)
Dcp\TestKubernetesService.cs (1)
65svc.Status.EffectivePort = svc.Spec.Port ?? Interlocked.Increment(ref _nextPort);
Eventing\DistributedApplicationBuilderEventingTests.cs (8)
27Interlocked.Increment(ref hitCount); 33Interlocked.Increment(ref hitCount); 58Interlocked.Increment(ref hitCount); 65Interlocked.Increment(ref hitCount); 91Interlocked.Increment(ref hitCount); 98Interlocked.Increment(ref hitCount); 125Interlocked.Increment(ref hitCount); 132Interlocked.Increment(ref hitCount);
Health\ResourceHealthCheckServiceTests.cs (4)
212Interlocked.Increment(ref hitCount); 252Interlocked.Increment(ref hitCount); 311Interlocked.Increment(ref healthCheckHits); 324Interlocked.Increment(ref eventHits);
Aspire.Microsoft.Data.SqlClient (2)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceSubscriber.cs (2)
54if ((Interlocked.Read(ref this.disposed) == 0) && 87if (Interlocked.CompareExchange(ref this.disposed, 1, 0) == 1)
Aspire.Microsoft.EntityFrameworkCore.SqlServer (2)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceSubscriber.cs (2)
54if ((Interlocked.Read(ref this.disposed) == 0) && 87if (Interlocked.CompareExchange(ref this.disposed, 1, 0) == 1)
BasicWebSite (2)
ActionDescriptorCreationCounter.cs (2)
16var callCount = Interlocked.Read(ref _callCount); 41Interlocked.Increment(ref _callCount);
Binding.ReliableSession.IntegrationTests (6)
NetHttpBindingTests.cs (3)
118Interlocked.Increment(ref callCount); 203Interlocked.Increment(ref httpRequestCount); 371Interlocked.Increment(ref httpRequestCount);
WSHttpBindingTests.cs (3)
118Interlocked.Increment(ref callCount); 203Interlocked.Increment(ref httpRequestCount); 371Interlocked.Increment(ref httpRequestCount);
Client.ChannelLayer.IntegrationTests (2)
DuplexChannelShapeTests.4.0.0.cs (2)
206Interlocked.Increment(ref Counter); 227Interlocked.Increment(ref Counter);
Client.ExpectedExceptions.IntegrationTests (4)
ExpectedExceptionTests.4.0.0.cs (2)
281if (Interlocked.Read(ref operationsQueued) >= operationCount) 300Interlocked.Increment(ref operationsQueued);
ExpectedExceptionTests.4.1.0.cs (2)
531if (Interlocked.Read(ref operationsQueued) >= operationCount) 550Interlocked.Increment(ref operationsQueued);
ClientSample (2)
Tcp\SocketAwaitable.cs (2)
51ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted)) 66var continuation = Interlocked.Exchange(ref _callback, _callbackCompleted);
dotnet-svcutil-lib (68)
FrameworkFork\Microsoft.Xml\Xml\schema\FacetChecker.cs (1)
1362Interlocked.CompareExchange(ref s_languagePattern, langRegex, null);
FrameworkFork\Microsoft.Xml\Xml\schema\Preprocessor.cs (1)
488Interlocked.CompareExchange<XmlSchema>(ref s_builtInSchemaForXmlNS, tempSchema, null);
FrameworkFork\Microsoft.Xml\Xml\schema\XmlSchema.cs (1)
547_schemaId = Interlocked.Increment(ref s_globalIdCounter);
FrameworkFork\Microsoft.Xml\Xml\schema\XmlSchemaSet.cs (1)
71Interlocked.CompareExchange<Object>(ref _internalSyncObject, o, null);
FrameworkFork\Microsoft.Xml\Xml\schema\XmlSchemaValidator.cs (4)
2495Interlocked.CompareExchange<XmlSchemaAttribute>(ref s_xsiTypeSO, tempXsiTypeSO, null); 2503Interlocked.CompareExchange<XmlSchemaAttribute>(ref s_xsiNilSO, tempxsiNilSO, null); 2512Interlocked.CompareExchange<XmlSchemaAttribute>(ref s_xsiSLSO, tempxsiSLSO, null); 2521Interlocked.CompareExchange<XmlSchemaAttribute>(ref s_xsiNoNsSLSO, tempxsiNoNsSLSO, null);
FrameworkFork\Microsoft.Xml\Xml\XmlCharType.cs (1)
400Interlocked.CompareExchange<object>(ref s_Lock, o, null);
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\ClassDataContract.cs (6)
154Interlocked.MemoryBarrier(); 312Interlocked.MemoryBarrier(); 341Interlocked.MemoryBarrier(); 1081Interlocked.MemoryBarrier(); 1217Interlocked.MemoryBarrier(); 1315Interlocked.MemoryBarrier();
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\CollectionDataContract.cs (5)
367Interlocked.MemoryBarrier(); 489Interlocked.MemoryBarrier(); 518Interlocked.MemoryBarrier(); 552Interlocked.MemoryBarrier(); 844Interlocked.MemoryBarrier();
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\EnumDataContract.cs (1)
327Interlocked.MemoryBarrier();
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\ExceptionDataContract.cs (2)
294Interlocked.MemoryBarrier(); 324Interlocked.MemoryBarrier();
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\XmlDataContract.cs (2)
186Interlocked.MemoryBarrier(); 287Interlocked.MemoryBarrier();
FrameworkFork\System.ServiceModel\Internals\System\Runtime\SignalGate.cs (2)
43lastState = Interlocked.CompareExchange(ref _state, GateState.SignalPending, GateState.Locked); 67lastState = Interlocked.CompareExchange(ref _state, GateState.Unlocked, GateState.Locked);
FrameworkFork\System.ServiceModel\System\IdentityModel\SecurityUniqueId.cs (1)
33return new SecurityUniqueId(prefix, Interlocked.Increment(ref s_nextId));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\CloseCollectionAsyncResult.cs (1)
96if (Interlocked.Decrement(ref _count) == 0)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpChannelFactory.cs (1)
1218if (Interlocked.CompareExchange(ref _httpRequestCompleted, 1, 0) == 0)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\LifetimeManager.cs (6)
112Interlocked.Increment(ref _busyWaiterCount); 119if (Interlocked.Decrement(ref _busyWaiterCount) == 0) 145Interlocked.Increment(ref _busyWaiterCount); 154if (Interlocked.Decrement(ref _busyWaiterCount) == 0) 210Interlocked.Increment(ref _busyWaiterCount); 245if (Interlocked.Decrement(ref _busyWaiterCount) == 0)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MessageHeaders.cs (1)
1190Interlocked.MemoryBarrier();
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\OpenCollectionAsyncResult.cs (1)
71if (Interlocked.Decrement(ref _count) == 0)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\ServiceChannel.cs (5)
823int updatedActivityCount = Interlocked.Decrement(ref _activityCount); 1139Interlocked.Increment(ref _activityCount); 2254if (Interlocked.Increment(ref _waitCount) == 2) 2384Interlocked.Exchange(ref _lastActivity, Ticks.Now); 2414long last = Interlocked.CompareExchange(ref _lastActivity, 0, 0);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\UriGenerator.cs (1)
38long nextId = Interlocked.Increment(ref _id);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WebSocketTransportDuplexSessionChannel.cs (7)
330if (Interlocked.CompareExchange(ref _cleanupStatus, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 510if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Cancelled, AsyncReceiveState.Started) == AsyncReceiveState.Started) 725int currentState = Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Started, AsyncReceiveState.Finished); 806if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Finished, AsyncReceiveState.Started) == AsyncReceiveState.Started) 1181if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 1259if (Interlocked.CompareExchange(ref _messageSourceCleanState, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted) 1301if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
FrameworkFork\System.ServiceModel\System\ServiceModel\Diagnostics\ServiceModelActivity.cs (1)
342newStopCount = Interlocked.Increment(ref _stopCount);
FrameworkFork\System.ServiceModel\System\ServiceModel\Diagnostics\TraceUtility.cs (1)
288return Interlocked.Increment(ref TraceUtility.s_messageNumber);
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\BufferedReceiveBinder.cs (4)
75if (Interlocked.CompareExchange(ref _pendingOperationSemaphore, 1, 0) == 0) 97if (Interlocked.CompareExchange(ref _pendingOperationSemaphore, 1, 0) == 0) 209Interlocked.Exchange(ref binder._pendingOperationSemaphore, 0); 251Interlocked.Exchange(ref binder._pendingOperationSemaphore, 0);
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\DuplexChannelBinder.cs (1)
792if (Interlocked.Increment(ref _waitCount) == 2)
FrameworkFork\System.ServiceModel\System\ServiceModel\InstanceContext.cs (1)
284object oldUserObject = Interlocked.Exchange(ref _userObject, newUserObject);
FrameworkFork\System.ServiceModel\System\ServiceModel\Security\SecurityUtils.cs (1)
1036return new SecurityUniqueId(prefix, Interlocked.Increment(ref s_nextId));
FrameworkFork\System.ServiceModel\System\ServiceModel\ServiceChannelManager.cs (8)
140Interlocked.Increment(ref _activityWaiterCount); 177Interlocked.Increment(ref _activityWaiterCount); 184if (Interlocked.Decrement(ref _activityWaiterCount) == 0) 216Interlocked.Increment(ref _activityWaiterCount); 226if (Interlocked.Decrement(ref _activityWaiterCount) == 0) 242if (Interlocked.Decrement(ref _activityWaiterCount) == 0) 297Interlocked.Increment(ref _activityWaiterCount); 304if (Interlocked.Decrement(ref _activityWaiterCount) == 0)
HttpStress (3)
Program.cs (3)
534Interlocked.Increment(ref counter); 535Interlocked.Increment(ref total); 599Interlocked.Increment(ref reuseAddressFailure);
InMemory.FunctionalTests (3)
ConnectionLimitTests.cs (2)
184if (e && Interlocked.Increment(ref opened) >= count) 192if (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)
152Interlocked.Increment(ref _waitingRequestCount); 160Interlocked.Decrement(ref _waitingRequestCount); 586Interlocked.Increment(ref _requestsInFlight); 593Interlocked.Decrement(ref _requestsInFlight);
Interop.FunctionalTests (5)
Http3\Http3RequestTests.cs (1)
769Interlocked.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)
167var renderId = Interlocked.Increment(ref _nextRenderId);
Microsoft.AspNetCore.Components.Tests (2)
NavigationManagerTest.cs (2)
319Interlocked.Increment(ref completedHandlerCount); 655Interlocked.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)
285return Interlocked.CompareExchange<CancellationTokenSource?>(ref _cacheExpirationTokenSource, null, null).Token; 487Interlocked.Exchange(ref _cacheExpirationTokenSource, new CancellationTokenSource())?.Cancel();
Microsoft.AspNetCore.DataProtection.Extensions (1)
TimeLimitedDataProtector.cs (1)
43retVal = Interlocked.CompareExchange(ref _innerProtectorWithTimeLimitedPurpose, newValue, null) ?? newValue;
Microsoft.AspNetCore.HeaderParsing (1)
HeaderRegistry.cs (1)
47var pos = Interlocked.Increment(ref _current);
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.Hosting.Tests (1)
HostingApplicationDiagnosticsTests.cs (1)
196if (Interlocked.Increment(ref measureCount) > 1)
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 (2)
Listener\ResponseHeaderTests.cs (1)
221Interlocked.Increment(ref connectCallbackInvocations);
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)
279if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None) 1314if (IsEnhanceYourCalmLimitEnabled && Interlocked.Increment(ref _enhanceYourCalmCount) > EnhanceYourCalmTickWindowCount * EnhanceYourCalmMaximumCount) 1403Interlocked.Exchange(ref _enhanceYourCalmCount, 0); 1823if (Interlocked.Exchange(ref _isClosed, 1) == 0) 1834Interlocked.Increment(ref _clientActiveStreamCount); 1839Interlocked.Decrement(ref _clientActiveStreamCount);
Internal\Http3\Http3Connection.cs (3)
92private long GetCurrentGoAwayStreamId() => Interlocked.Read(ref _highestOpenedRequestStreamId) + 4; 122if (Interlocked.CompareExchange(ref _gracefulCloseInitiator, initiator, GracefulCloseInitiator.None) == GracefulCloseInitiator.None) 149if (Interlocked.Exchange(ref _stoppedAcceptingStreams, 1) == 0)
Internal\Http3\Http3ControlStream.cs (1)
110if (Interlocked.Exchange(ref _isClosed, 1) == 0)
Internal\Http3\Http3Stream.cs (1)
573if (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) 181Interlocked.Exchange(ref _timeoutTimestamp, long.MaxValue); 192Interlocked.Exchange(ref _timeoutTimestamp, Interlocked.Read(ref _lastTimestamp) + timeoutTicks + _heartbeatIntervalTicks); 289var 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)
23if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0) 57if (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)
23if (Interlocked.CompareExchange(ref _doingWork, 1, 0) == 0) 57if (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 (3)
Internal\InvocationRequest.cs (1)
45return Activity != null && Interlocked.Exchange(ref _isActivityStopping, 1) == 0;
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 (33)
BackEnd\BuildManager\BuildManager.cs (3)
1514return Interlocked.Increment(ref s_nextBuildId); 2189int newId = Interlocked.Increment(ref s_nextBuildRequestConfigurationId); 2196newId = Interlocked.Increment(ref s_nextBuildRequestConfigurationId);
BackEnd\BuildManager\BuildSubmission.cs (1)
109bool 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)
400return Interlocked.Add(ref _nextEvaluationId, MaxCPUCount + 2); 413return Interlocked.Add(ref _nextProjectId, MaxCPUCount + 2); 425return Interlocked.Increment(ref _nextTargetId); 437return Interlocked.Increment(ref _nextTaskId);
BackEnd\Components\RequestBuilder\RequestBuilder.cs (2)
1465var prev = Interlocked.CompareExchange(ref _availableThreads, count - 1, count); 1487Interlocked.Increment(ref _availableThreads);
BackEnd\Components\Scheduler\Scheduler.cs (1)
1391var loggedWarnings = Interlocked.CompareExchange(ref _loggedWarningsForProxyBuildsOnOutOfProcNodes, 1, 0);
Construction\ProjectRootElement.cs (1)
2129Version = 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\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)
716Interlocked.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);
ObjectModelRemoting\LinkedObjectFactory.cs (4)
255Interlocked.CompareExchange(ref _immutableInstance, instance, null); 279Interlocked.CompareExchange(ref _immutableInstance, instance, null); 302Interlocked.CompareExchange(ref _immutableInstance, instance, null); 334Interlocked.CompareExchange(ref _immutableInstance, instance, null);
TypeLoader.cs (3)
353if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 357if (Interlocked.Read(ref _haveScannedPublicTypes) == 0) 360Interlocked.Exchange(ref _haveScannedPublicTypes, ~0);
Microsoft.Build.Engine.OM.UnitTests (9)
Construction\ProjectRootElement_Tests.cs (8)
1041var current = Interlocked.Increment(ref counter) - 1; 1045if (Interlocked.Decrement(ref remaining) == 0) 1064var current = Interlocked.Increment(ref counter) - 1; 1070if (Interlocked.Decrement(ref remaining) == 0) 1112var current = Interlocked.Increment(ref counter) - 1; 1117if (Interlocked.Decrement(ref remaining) == 0) 1134var current = Interlocked.Increment(ref counter) - 1; 1138if (Interlocked.Decrement(ref remaining) == 0)
ObjectModelRemoting\RemoteProjectsProviderMock\ExporterMock.cs (1)
158this.CollectionId = (UInt32)Interlocked.Increment(ref _collecitonId);
Microsoft.Build.Engine.UnitTests (3)
ProjectCache\ProjectCacheTests.cs (3)
293var queryId = Interlocked.Increment(ref _nextId); 1597Interlocked.Increment(ref nonCacheHitCount); 1602Interlocked.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)
2319Interlocked.Increment(ref incremented);
Microsoft.CodeAnalysis (87)
Binding\UseSiteInfo.cs (2)
538Interlocked.CompareExchange(ref _info, info, Sentinel); 551info = Interlocked.CompareExchange(ref _info, info, null);
CodeGen\CompilationTestData.cs (1)
82Interlocked.CompareExchange(ref _lazyMethodsByName, methodsByName, null);
CodeGen\PrivateImplementationDetails.cs (3)
148var wasFrozen = Interlocked.Exchange(ref _frozen, 1); 304Interlocked.CompareExchange(ref _mvidField, new ModuleVersionIdField(this, mvidType), null); 316Interlocked.CompareExchange(ref _moduleCancellationTokenField, new ModuleCancellationTokenField(this, cancellationTokenType), null);
Collections\CachingDictionary.cs (2)
158localMap = Interlocked.CompareExchange(ref _map, concurrentMap, null); 256var replacedMap = Interlocked.CompareExchange(ref _map, fullyPopulatedMap, currentMap);
Collections\SmallConcurrentSetOfInts.cs (2)
104nextSet = Interlocked.CompareExchange(ref set._next, tail, null); 132val = Interlocked.CompareExchange(ref slot, i, unoccupied);
Collections\TemporaryArray`1.cs (1)
153Interlocked.Exchange(ref _builder, null)?.Free();
CommandLine\TouchedFileLogger.cs (2)
67var readFiles = Interlocked.Exchange( 92var writtenFiles = Interlocked.Exchange(
Compilation\CommonModuleCompilationState.cs (2)
22Interlocked.MemoryBarrier(); 48Interlocked.CompareExchange(ref _lazyStateMachineTypes, new Dictionary<TMethodSymbol, TNamedTypeSymbol>(), null);
Compilation\Compilation.cs (2)
1829Interlocked.Increment(ref _eventQueueEnqueuePendingCount); 1834Interlocked.Decrement(ref _eventQueueEnqueuePendingCount);
Diagnostic\CustomObsoleteDiagnosticInfo.cs (1)
47Interlocked.CompareExchange(ref _descriptor, CreateDescriptor(), null);
Diagnostic\DiagnosticBag.cs (1)
305return Interlocked.CompareExchange(ref _lazyBag, newBag, null) ?? newBag;
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
2426Interlocked.CompareExchange(ref _lazyCoreActions, createCoreActions(), null);
DiagnosticAnalyzer\AnalyzerExecutor.cs (2)
1170Interlocked.Add(ref totalTicks.Value, elapsed); 1506Interlocked.CompareExchange(ref _lazyControlFlowGraphMap, new ConcurrentDictionary<IOperation, ControlFlowGraph>(), null);
DiagnosticAnalyzer\AnalyzerFileReference.cs (1)
456Interlocked.CompareExchange(ref _lazyExtensionTypeNameMap, analyzerTypeNameMap, null);
DiagnosticAnalyzer\CompilationAnalysisValueProviderFactory.cs (1)
21Interlocked.CompareExchange(ref _lazySharedStateProviderMap, new Dictionary<object, object>(), null);
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (3)
231Interlocked.CompareExchange( 247Interlocked.CompareExchange( 269Interlocked.CompareExchange(ref _lazyGlobalSuppressions, suppressions, null);
DiaSymReader\Writer\SymUnmanagedWriterImpl.cs (1)
104var symWriter = Interlocked.Exchange(ref _symWriter, null);
Emit\CommonPEModuleBuilder.cs (7)
822Interlocked.CompareExchange(ref NestedTypes, new ConcurrentQueue<Cci.INestedTypeDefinition>(), null); 914Interlocked.CompareExchange(ref defs.Methods, new ConcurrentQueue<Cci.IMethodDefinition>(), null); 927Interlocked.CompareExchange(ref defs.Properties, new ConcurrentQueue<Cci.IPropertyDefinition>(), null); 940Interlocked.CompareExchange(ref defs.Fields, new ConcurrentQueue<Cci.IFieldDefinition>(), null); 959Interlocked.CompareExchange(ref _lazySynthesizedNamespaceMembers, new ConcurrentDictionary<INamespaceSymbolInternal, ConcurrentQueue<INamespaceOrTypeSymbolInternal>>(), null); 1059if (Interlocked.CompareExchange(ref _lazyArrayMethods, result, null) != null) 1093if (Interlocked.CompareExchange(ref _lazyPrivateImplementationDetails, result, null) != null)
Emit\NoPia\CommonEmbeddedEvent.cs (1)
84Interlocked.CompareExchange(ref _isUsedForComAwareEventBinding, 1, 0) == 0))
InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value; 21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue); 117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue); 152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
InternalUtilities\SemaphoreSlimExtensions.cs (1)
47var semaphoreToDispose = Interlocked.Exchange(ref _semaphore, null);
InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
InternalUtilities\StringTable.cs (1)
672return Interlocked.Increment(ref StringTable.s_sharedRandom);
InternalUtilities\ThreadSafeFlagOperations.cs (2)
23while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState); 39while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState);
MetadataReader\PEAssembly.cs (1)
183Interlocked.CompareExchange(ref _lazyInternalsVisibleToMap, BuildInternalsVisibleToMap(), null);
MetadataReader\PEModule.cs (4)
268Interlocked.CompareExchange(ref _lazyMetadataReader, newReader, null); 2640Interlocked.CompareExchange( 2648Interlocked.CompareExchange( 2676while (Interlocked.CompareExchange(
MetadataReference\AssemblyMetadata.cs (2)
345createdModulesUsed = Interlocked.CompareExchange(ref _lazyData, newData, null) == null; 373var previousData = Interlocked.Exchange(ref _lazyData, Data.Disposed);
MetadataReference\ModuleMetadata.cs (1)
303var onDispose = Interlocked.Exchange(ref _onDispose, null);
MetadataReference\PortableExecutableReference.cs (1)
57Interlocked.CompareExchange(ref _lazyDocumentation, CreateDocumentationProvider(), null);
Operations\ControlFlowGraph.cs (4)
256Interlocked.CompareExchange(ref _lazyLocalFunctionsGraphs, new ControlFlowGraph[LocalFunctions.Length], null); 265Interlocked.CompareExchange(ref localFunctionGraph, graph, null); 303Interlocked.CompareExchange(ref _lazyAnonymousFunctionsGraphs, new ControlFlowGraph[_anonymousFunctionsMap.Count], null); 312Interlocked.CompareExchange(ref anonymousFlowGraph, graph, null);
Operations\ControlFlowGraphBuilder.CaptureIdDispenser.cs (1)
17return Interlocked.Increment(ref _captureId);
ReferenceManager\CommonReferenceManager.State.cs (1)
449Interlocked.Exchange(ref _isBound, 1);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (2)
29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (2)
29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (2)
29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\RoslynImmutableInterlocked.cs (2)
620Interlocked.MemoryBarrier(); 633Interlocked.MemoryBarrier();
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
StrongName\StrongNameKeys.cs (1)
160Interlocked.Exchange(ref s_lastSeenKeyPair, cachedKeyPair);
Symbols\Attributes\CustomAttributesBag.cs (2)
73var setOnOurThread = Interlocked.CompareExchange(ref _earlyDecodedWellKnownAttributeData, data, null) == null; 88var setOnOurThread = Interlocked.CompareExchange(ref _decodedWellKnownAttributeData, data, null) == null;
Symbols\Attributes\SecurityWellKnownAttributeData.cs (2)
37Interlocked.CompareExchange(ref _lazySecurityActions, new byte[totalSourceAttributes], null); 51Interlocked.CompareExchange(ref _lazyPathsForPermissionSetFixup, new string[totalSourceAttributes], null);
Syntax\SyntaxAnnotation.cs (1)
34_id = System.Threading.Interlocked.Increment(ref s_nextId);
Syntax\SyntaxNode.cs (7)
145Interlocked.CompareExchange(ref field, green.CreateRed(this, this.GetChildPosition(slot)), null); 163Interlocked.CompareExchange(ref field, green.CreateRed(this, this.Position), null); 180Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.GetChildPosition(slot)), null); 198Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.Position), null); 221Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(slot)), null); 243Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(1)), null); 278if (Interlocked.CompareExchange(ref slot, newWeakReference, previousWeakReference) == previousWeakReference)
Text\SourceText.cs (2)
479Interlocked.CompareExchange(ref _lazyContainer, new StaticContainer(this), null); 942return info ?? Interlocked.CompareExchange(ref _lazyLineInfo, info = GetLinesCore(), null) ?? info;
Microsoft.CodeAnalysis.CodeStyle (27)
src\Compilers\Core\Portable\Collections\TemporaryArray`1.cs (1)
153Interlocked.Exchange(ref _builder, null)?.Free();
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value; 21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue); 117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue); 152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
src\Compilers\Core\Portable\InternalUtilities\SemaphoreSlimExtensions.cs (1)
47var semaphoreToDispose = Interlocked.Exchange(ref _semaphore, null);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
672return Interlocked.Increment(ref StringTable.s_sharedRandom);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (2)
29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (2)
29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (2)
29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\RoslynImmutableInterlocked.cs (2)
620Interlocked.MemoryBarrier(); 633Interlocked.MemoryBarrier();
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\Logger.cs (2)
34return Interlocked.Exchange(ref s_currentLogger, logger); 154=> Interlocked.Increment(ref s_lastUniqueBlockId);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AnnotationTable.cs (1)
46var id = Interlocked.Increment(ref _globalId);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CancellableLazy`1.cs (2)
58Interlocked.Exchange<Func<CancellationToken, T>?>(ref _valueFactory, null); 61Interlocked.Exchange(ref _gate, null);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\RoslynParallel.NetFramework.cs (2)
459Interlocked.Increment(ref _completionRefCount); 478public bool SignalWorkerCompletedIterating() => Interlocked.Decrement(ref _completionRefCount) == 0;
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Workspace\Mef\MefWorkspaceServices.cs (1)
75var allLanguageServices = Interlocked.Exchange(ref _languageServicesMap, _languageServicesMap.Clear());
Microsoft.CodeAnalysis.Collections.Package (8)
ImmutableSegmentedDictionary`2+PrivateMarshal.cs (2)
29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
ImmutableSegmentedHashSet`1+PrivateMarshal.cs (2)
29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
ImmutableSegmentedList`1+PrivateMarshal.cs (2)
29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
RoslynImmutableInterlocked.cs (2)
620Interlocked.MemoryBarrier(); 633Interlocked.MemoryBarrier();
Microsoft.CodeAnalysis.CSharp (228)
Binder\Binder.cs (2)
508Interlocked.CompareExchange(ref _lazyConversions, new Conversions(this), null); 522Interlocked.CompareExchange(ref _lazyOverloadResolution, new OverloadResolution(this), null);
Binder\ExecutableCodeBinder.cs (1)
87Interlocked.CompareExchange(ref _lazyBinderMap, map, null);
Binder\LocalInProgressBinder.cs (1)
42Interlocked.CompareExchange(ref _localSymbol, local, null);
Binder\LockOrUsingBinder.cs (2)
71Interlocked.CompareExchange(ref _lazyLockedOrDisposedVariables, lockedOrDisposedVariables, null); 93Interlocked.CompareExchange(ref _lazyExpressionAndDiagnostics, new ExpressionAndDiagnostics(boundExpression, expressionDiagnostics.ToReadOnlyAndFree()), null);
Binder\Semantics\Conversions\ConversionsBase.cs (1)
58Interlocked.CompareExchange(ref _lazyOtherNullability, WithNullabilityCore(includeNullability), null);
Binder\SwitchBinder.cs (1)
69Interlocked.CompareExchange(ref _switchGoverningExpression, boundSwitchExpression, null);
Binder\WithClassTypeParametersBinder.cs (1)
46Interlocked.CompareExchange(ref _lazyTypeParameterMap, result, null);
Binder\WithCrefTypeParametersBinder.cs (1)
37Interlocked.CompareExchange(ref _lazyTypeParameterMap, map, null);
Binder\WithExternAndUsingAliasesBinder.cs (2)
73Interlocked.CompareExchange(ref _lazyImportChain, BuildImportChain(), null); 155Interlocked.CompareExchange(ref _lazyUsingAliasesMap, _declaringSymbol.GetUsingAliasesMap(_declarationSyntax, basesBeingResolved), null);
Binder\WithMethodTypeParametersBinder.cs (1)
49Interlocked.CompareExchange(ref _lazyTypeParameterMap, result, null);
Binder\WithUsingNamespacesAndTypesBinder.cs (2)
243Interlocked.CompareExchange(ref _lazyImportChain, importChain, null); 322Interlocked.CompareExchange(ref _lazyFullImports,
BoundTree\UnboundLambda.cs (2)
571Interlocked.Increment(ref data.LambdaBindingCount); 1168Interlocked.CompareExchange(ref _errorBinding, ReallyBindForErrorRecovery(), null);
Compilation\BuiltInOperators.cs (2)
241Interlocked.CompareExchange(ref _builtInUnaryOperators, allOperators, null); 672Interlocked.CompareExchange(ref _builtInOperators, allOperators, null);
Compilation\CSharpCompilation.cs (11)
87Interlocked.CompareExchange(ref _conversions, new BuckStopsHereBinder(this, associatedFileIdentifier: null).Conversions, null); 1429Interlocked.CompareExchange(ref _lazyGlobalNamespace, result, null); 1495Interlocked.CompareExchange(ref _externAliasTargets, new ConcurrentDictionary<string, NamespaceSymbol>(), null); 1540Interlocked.CompareExchange(ref _lazyScriptClass, BindScriptClass()!, ErrorTypeSymbol.UnknownResultType); 1805Interlocked.CompareExchange(ref _lazyHostObjectTypeSymbol, symbol, null); 1913Interlocked.CompareExchange(ref _lazyEntryPoint, entryPoint, null); 2570binderFactories = Interlocked.CompareExchange(ref cachedBinderFactories, binderFactories, null) ?? binderFactories; 2598if (Interlocked.CompareExchange(ref slot!, newWeakReference, previousWeakReference) == previousWeakReference) 2617if (_lazyCompilationUnitCompletedTrees == null) Interlocked.CompareExchange(ref _lazyCompilationUnitCompletedTrees, new HashSet<SyntaxTree>(), null); 2842Interlocked.CompareExchange(ref _lazyDeclarationDiagnostics, diagnostics, null); 3207var recent = Interlocked.CompareExchange(ref _usageOfUsingsRecordedInTrees, updated, current);
Compilation\SyntaxAndDeclarationManager.cs (1)
43Interlocked.CompareExchange(ref _lazyState, CreateState(this.ExternalSyntaxTrees, this.ScriptClassName, this.Resolver, this.MessageProvider, this.IsSubmission), null);
Compilation\SyntaxTreeSemanticModel.cs (1)
1224Interlocked.CompareExchange(ref _globalStatementLabels, new ScriptLocalScopeBinder.Labels(scriptInitializer, (CompilationUnitSyntax)parent), null);
Compiler\MethodCompiler.cs (1)
2025Interlocked.CompareExchange(ref inMethodBinder.IdentifierMap, identifierMap, null);
Declarations\DeclarationTable.Cache.cs (3)
45Interlocked.CompareExchange( 60Interlocked.CompareExchange(ref _typeNames, GetTypeNames(this.MergedRoot), comparand: null); 71Interlocked.CompareExchange(ref _namespaceNames, GetNamespaceNames(this.MergedRoot), comparand: null);
Declarations\DeclarationTable.cs (4)
108Interlocked.CompareExchange(ref _mergedRoot, CalculateMergedRoot(compilation), null); 246Interlocked.CompareExchange(ref _typeNames, GetMergedTypeNames(), comparand: null); 257Interlocked.CompareExchange(ref _namespaceNames, GetMergedNamespaceNames(), comparand: null); 268Interlocked.CompareExchange(ref _referenceDirectives, GetMergedReferenceDirectives(), comparand: null);
Declarations\MergedTypeDeclaration.cs (1)
247Interlocked.CompareExchange(ref _lazyMemberNames, names, null);
DocumentationComments\PEDocumentationCommentUtils.cs (1)
29Interlocked.CompareExchange(
DocumentationComments\SourceDocumentationCommentUtils.cs (1)
27Interlocked.CompareExchange(ref lazyXmlText, xmlText, null);
Emitter\EditAndContinue\PEDeltaAssemblyBuilder.cs (1)
334Interlocked.CompareExchange(ref _lazyHotReloadExceptionType, symbol, comparand: null);
Emitter\Model\FunctionPointerTypeSymbolAdapter.cs (1)
31Interlocked.CompareExchange(ref _lazySignature, new FunctionPointerMethodSignature(AdaptedFunctionPointerTypeSymbol.Signature), null);
Emitter\Model\PEModuleBuilder.cs (2)
1467Interlocked.CompareExchange(ref _fixedImplementationTypes, new Dictionary<FieldSymbol, NamedTypeSymbol>(), null); 1855Interlocked.CompareExchange(
Emitter\NoPia\EmbeddedTypesManager.cs (2)
68if (TypeSymbol.Equals(Interlocked.CompareExchange(ref _lazySystemStringType, typeSymbol, ErrorTypeSymbol.UnknownResultType), ErrorTypeSymbol.UnknownResultType, TypeCompareKind.ConsiderEverything2)) 105if (Interlocked.CompareExchange(ref lazyMethod, symbol, ErrorMethodSymbol.UnknownMethod) == ErrorMethodSymbol.UnknownMethod)
Errors\LazyDiagnosticInfo.cs (1)
22Interlocked.CompareExchange(ref _lazyInfo, ResolveInfo() ?? CSDiagnosticInfo.VoidDiagnosticInfo, null);
FlowAnalysis\ControlFlowAnalysis.cs (2)
118Interlocked.CompareExchange(ref _regionEndPointIsReachable, endIsReachable, null); 119Interlocked.CompareExchange(ref _regionStartPointIsReachable, startIsReachable, null);
FlowAnalysis\CSharpDataFlowAnalysis.cs (2)
85Interlocked.CompareExchange(ref _unassignedVariables, result, null); 366Interlocked.CompareExchange(ref _unassignedVariableAddressOfSyntaxes, result, null);
Parser\Directives.cs (1)
130=> Interlocked.CompareExchange(ref Unsafe.AsRef(in location._directives), value._directives, null);
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (1)
315return Interlocked.CompareExchange(ref _lazyAliasMap, map, null) ?? map;
Symbols\AliasSymbol.cs (2)
324if (Interlocked.CompareExchange(ref _aliasTarget, symbol, null) is null) 329bool won = Interlocked.Exchange(ref _aliasTargetDiagnostics, newDiagnostics) == null;
Symbols\AnonymousTypes\AnonymousTypeManager.Templates.cs (2)
126Interlocked.CompareExchange(ref _lazyAnonymousTypeTemplates, 148Interlocked.CompareExchange(ref _lazyAnonymousDelegates,
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.TypeOrDelegateTemplateSymbol.cs (2)
81var oldValue = Interlocked.CompareExchange(ref _nameAndIndex, value, null); 107if (ReferenceEquals(Interlocked.CompareExchange(ref _smallestLocation, location, currentSmallestLocation), currentSmallestLocation))
Symbols\Attributes\PEAttributeData.cs (2)
93Interlocked.CompareExchange(ref _lazyAttributeConstructor, attributeConstructor, null); 94Interlocked.CompareExchange(ref _lazyAttributeClass, (NamedTypeSymbol?)attributeClass, ErrorTypeSymbol.UnknownResultType); // Serves as a flag, so do it last.
Symbols\Compilation_UsedAssemblies.cs (1)
245Interlocked.CompareExchange(ref _lazyUsedAssemblyReferences, new ConcurrentSet<AssemblySymbol>(), null);
Symbols\Compilation_WellKnownMembers.cs (4)
95Interlocked.CompareExchange(ref _lazyWellKnownTypeMembers, wellKnownTypeMembers, null); 109Interlocked.CompareExchange(ref _lazyWellKnownTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType); 132Interlocked.CompareExchange(ref _lazyWellKnownTypes, new NamedTypeSymbol[(int)WellKnownTypes.Count], null); 178if (Interlocked.CompareExchange(ref _lazyWellKnownTypes[index], result, null) is object)
Symbols\FunctionTypeSymbol.cs (2)
86var result = Interlocked.CompareExchange(ref _lazyDelegateType, delegateType, Uninitialized); 91Interlocked.Increment(ref data.InferredDelegateCount);
Symbols\Metadata\PE\PEAssemblySymbol.cs (2)
311Interlocked.CompareExchange( 330Interlocked.CompareExchange(ref _lazyObsoleteAttributeData, experimentalData, ObsoleteAttributeData.Uninitialized);
Symbols\Metadata\PE\PEEventSymbol.cs (1)
268Interlocked.CompareExchange(ref _lazyDeclaredAccessibility, (int)accessibility, UnsetAccessibility);
Symbols\Metadata\PE\PEFieldSymbol.cs (2)
342Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null); 505Interlocked.CompareExchange(
Symbols\Metadata\PE\PEMethodSymbol.cs (2)
1363Interlocked.CompareExchange(ref AccessUncommonFields()._lazyExplicitClassOverride, uniqueClassOverride, null); 1712Interlocked.CompareExchange(ref AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0);
Symbols\Metadata\PE\PEModuleSymbol.cs (7)
509Interlocked.CompareExchange(ref _lazyTypeNames, _module.TypeNames.AsCaseSensitiveCollection(), null); 522Interlocked.CompareExchange(ref _lazyNamespaceNames, _module.NamespaceNames.AsCaseSensitiveCollection(), null); 558Interlocked.CompareExchange(ref _lazyEventRegistrationTokenSymbol, 575Interlocked.CompareExchange(ref _lazyEventRegistrationTokenTableSymbol, 592Interlocked.CompareExchange(ref _lazySystemTypeSymbol, 831Interlocked.CompareExchange( 878Interlocked.CompareExchange(ref _lazyObsoleteAttributeData, experimentalData, ObsoleteAttributeData.Uninitialized);
Symbols\Metadata\PE\PENamedTypeSymbol.cs (11)
105return Interlocked.CompareExchange(ref _lazyUncommonProperties, result, null) ?? result; 477Interlocked.CompareExchange(ref _lazyBaseType, MakeAcyclicBaseType(), ErrorTypeSymbol.UnknownResultType); 525Interlocked.CompareExchange(ref _lazyDeclaredBaseType, baseType, ErrorTypeSymbol.UnknownResultType); 848Interlocked.CompareExchange(ref _lazyMemberNames, CreateReadOnlyMemberNames(names), null); 1258Interlocked.CompareExchange(ref uncommon.lazyEnumUnderlyingType, underlyingType, null); 1461var exchangeResult = Interlocked.CompareExchange(ref _lazyMembersByName, membersDict, null); 1482Interlocked.Exchange(ref _lazyMemberNames, memberNames); 1574var exchangeResult = Interlocked.CompareExchange(ref _lazyNestedTypes, typesDict, null); 2215Interlocked.CompareExchange(ref uncommon.lazyDefaultMemberName, defaultMemberName ?? "", null); 2364Interlocked.CompareExchange(ref uncommon.lazyComImportCoClassType, coClassType, ErrorTypeSymbol.UnknownResultType); 2505Interlocked.CompareExchange(
Symbols\Metadata\PE\PENamespaceSymbol.cs (3)
265Interlocked.CompareExchange(ref this.lazyNamespaces, namespaces, null); 314Interlocked.CompareExchange(ref _lazyNoPiaLocalTypes, noPiaLocalTypes, null); 317var original = Interlocked.CompareExchange(ref this.lazyTypes, typesDict, null);
Symbols\Metadata\PE\PENestedNamespaceSymbol.cs (1)
137Interlocked.Exchange(ref _typesByNS, null);
Symbols\Metadata\PE\PEParameterSymbol.cs (1)
565Interlocked.CompareExchange(ref _lazyDefaultValue, value, ConstantValue.Unset);
Symbols\Metadata\PE\PEPropertySymbol.cs (2)
537Interlocked.CompareExchange(ref _declaredAccessibility, (int)accessibility, UnsetAccessibility); 1054Interlocked.CompareExchange(ref AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0);
Symbols\Metadata\PE\PETypeParameterSymbol.cs (1)
694Interlocked.CompareExchange(ref _lazyBounds, bounds, TypeParameterBounds.Unset);
Symbols\MetadataOrSourceAssemblySymbol.cs (11)
90Interlocked.CompareExchange(ref _lazySpecialTypes, 94if ((object)Interlocked.CompareExchange(ref _lazySpecialTypes[(int)typeId], corType, null) != null) 102Interlocked.Increment(ref _cachedSpecialTypes); 128Interlocked.CompareExchange(ref _lazyTypeNames, UnionCollection<string>.Create(this.Modules, m => m.TypeNames), null); 141Interlocked.CompareExchange(ref _lazyNativeIntegerTypes, new NativeIntegerTypeSymbol[2], null); 153Interlocked.CompareExchange(ref _lazyNativeIntegerTypes[index], new NativeIntegerTypeSymbol(underlyingType), null); 165Interlocked.CompareExchange(ref _lazyNamespaceNames, UnionCollection<string>.Create(this.Modules, m => m.NamespaceNames), null); 201Interlocked.CompareExchange(ref _lazySpecialTypeMembers, specialTypeMembers, null); 213Interlocked.CompareExchange(ref _lazySpecialTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType); 273Interlocked.CompareExchange(ref _assembliesToWhichInternalAccessHasBeenAnalyzed, new ConcurrentDictionary<AssemblySymbol, IVTConclusion>(), null); 289Interlocked.CompareExchange(ref _lazyTypeConversions, new TypeConversions(this), null);
Symbols\MissingCorLibrarySymbol.cs (3)
48Interlocked.CompareExchange(ref _lazyTypeConversions, new TypeConversions(this), null); 71Interlocked.CompareExchange(ref _lazySpecialTypes, 79Interlocked.CompareExchange(ref _lazySpecialTypes[(int)type], corType, null);
Symbols\MissingMetadataTypeSymbol.cs (3)
277Interlocked.CompareExchange(ref _lazyContainingNamespace, container, null); 301Interlocked.CompareExchange(ref _lazyTypeId, (int)typeId, -1); 326Interlocked.CompareExchange(ref _lazyErrorInfo, errorInfo, null);
Symbols\NativeIntegerTypeSymbol.cs (1)
230Interlocked.CompareExchange(ref _lazyTypeMap, new NativeIntegerTypeMap(this), null);
Symbols\NonMissingAssemblySymbol.cs (1)
66Interlocked.CompareExchange(ref _globalNamespace, result, null);
Symbols\ObsoleteAttributeHelpers.cs (1)
36Interlocked.CompareExchange(ref data, obsoleteAttributeData, ObsoleteAttributeData.Uninitialized);
Symbols\ParameterSignature.cs (1)
69Interlocked.CompareExchange(ref lazySignature, MakeParamTypesAndRefKinds(parameters), null);
Symbols\PublicModel\ArrayTypeSymbol.cs (1)
49Interlocked.CompareExchange(ref _lazyElementType, _underlying.ElementTypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\DiscardSymbol.cs (1)
29Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\EventSymbol.cs (1)
31Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\FieldSymbol.cs (1)
44Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\LocalSymbol.cs (1)
31Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\MethodSymbol.cs (2)
85Interlocked.CompareExchange(ref _lazyReturnType, _underlying.ReturnTypeWithAnnotations.GetPublicSymbol(), null); 179Interlocked.CompareExchange(ref _lazyReceiverType, _underlying.ReceiverType?.GetITypeSymbol(_underlying.ReceiverNullableAnnotation), null);
Symbols\PublicModel\ParameterSymbol.cs (1)
32Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\PointerTypeSymbol.cs (1)
40Interlocked.CompareExchange(ref _lazyPointedAtType, _underlying.PointedAtTypeWithAnnotations.GetPublicSymbol(), null);
Symbols\PublicModel\PropertySymbol.cs (1)
37Interlocked.CompareExchange(ref _lazyType, _underlying.TypeWithAnnotations.GetPublicSymbol(), null);
Symbols\Retargeting\RetargetingMethodSymbol.cs (2)
135Interlocked.CompareExchange(ref _lazyReturnType, 253Interlocked.CompareExchange(ref _lazyUnmanagedAttributeData, data, UnmanagedCallersOnlyAttributeData.Uninitialized);
Symbols\Retargeting\RetargetingNamedTypeSymbol.cs (2)
296Interlocked.CompareExchange(ref _lazyBaseType, acyclicBase, ErrorTypeSymbol.UnknownResultType); 334Interlocked.CompareExchange(ref _lazyDeclaredBaseType, declaredBase, ErrorTypeSymbol.UnknownResultType);
Symbols\Retargeting\RetargetingParameterSymbol.cs (1)
46Interlocked.CompareExchange(ref _lazyTypeWithAnnotations,
Symbols\Retargeting\RetargetingPropertySymbol.cs (1)
74Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null);
Symbols\Source\GlobalExpressionVariable.cs (1)
138if (Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null) == null)
Symbols\Source\IndexedTypeParameterSymbol.cs (1)
71Interlocked.CompareExchange(ref s_parameterPool, newPool, initialPool);
Symbols\Source\LocalFunctionOrSourceMemberMethodSymbol.cs (1)
36Interlocked.CompareExchange(ref _lazyIteratorElementType, new TypeWithAnnotations.Boxed(elementType), TypeWithAnnotations.Boxed.Sentinel);
Symbols\Source\LocalFunctionSymbol.cs (1)
302Interlocked.CompareExchange(ref _lazyReturnType, new TypeWithAnnotations.Boxed(returnType), null);
Symbols\Source\QuickAttributeChecker.cs (1)
39Interlocked.CompareExchange(ref _lazyPredefinedQuickAttributeChecker, CreatePredefinedQuickAttributeChecker(), null);
Symbols\Source\SourceAssemblySymbol.cs (7)
198Interlocked.CompareExchange(ref lazyAssemblyIdentity, ComputeIdentity(), null); 547Interlocked.CompareExchange(ref _lazyStrongNameKeys, ComputeStrongNameKeys(), null); 1178Interlocked.CompareExchange(ref _lazyOmittedAttributeIndices, new ConcurrentSet<int>(), null); 1366Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, CustomAttributesBag<CSharpAttributeData>.Empty, null); 1447if (Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, netModuleAttributesBag, null) == null) 2163Interlocked.CompareExchange(ref _optimisticallyGrantedInternalsAccess, new ConcurrentDictionary<AssemblySymbol, bool>(), null); 2305Interlocked.CompareExchange(ref lazyInternalsVisibleToMap,
Symbols\Source\SourceComplexParameterSymbol.cs (2)
250var previousValue = Interlocked.CompareExchange( 596bagCreatedOnThisThread = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null;
Symbols\Source\SourceEventSymbol.cs (1)
645Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
Symbols\Source\SourceFieldSymbol.cs (2)
363Interlocked.CompareExchange(ref _lazyConstantEarlyDecodingValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset); 367if (Interlocked.CompareExchange(ref _lazyConstantValue, value, Microsoft.CodeAnalysis.ConstantValue.Unset) == Microsoft.CodeAnalysis.ConstantValue.Unset)
Symbols\Source\SourceFixedFieldSymbol.cs (1)
127if (Interlocked.CompareExchange(ref _fixedSize, size, FixedSizeNotInitialized) == FixedSizeNotInitialized)
Symbols\Source\SourceLocalSymbol.cs (2)
402Interlocked.CompareExchange(ref _type, new TypeWithAnnotations.Boxed(newType), null); 589Interlocked.CompareExchange(ref _constantTuple, new EvaluatedConstant(value, diagnostics.ToReadOnlyAndFree()), null);
Symbols\Source\SourceMemberContainerSymbol.cs (7)
1305if (Interlocked.CompareExchange(ref _lazyTypeMembers, MakeTypeMembers(diagnostics), null) == null) 1597Interlocked.CompareExchange(ref _lazyEarlyAttributeDecodingMembersDictionary, membersByName, null); 1658var alreadyKnown = Interlocked.CompareExchange(ref _lazyMembersAndInitializers, membersAndInitializers, null); 1762if (Interlocked.CompareExchange(ref _lazyMembersDictionary, membersDictionary, null) == null) 2348Interlocked.CompareExchange(ref _lazyKnownCircularStruct, (int)ThreeState.False, (int)ThreeState.Unknown); 2355if (Interlocked.CompareExchange(ref _lazyKnownCircularStruct, value, (int)ThreeState.Unknown) == (int)ThreeState.Unknown) 3236var alreadyKnown = Interlocked.CompareExchange(ref _lazyDeclaredMembersAndInitializers, declaredMembersAndInitializers, DeclaredMembersAndInitializers.UninitializedSentinel);
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (1)
52if (Interlocked.CompareExchange(
Symbols\Source\SourceMemberFieldSymbol.cs (1)
589if (Interlocked.CompareExchange(ref _lazyTypeAndRefKind, new TypeAndRefKind(refKind, type.WithModifiers(this.RequiredCustomModifiers)), null) == null)
Symbols\Source\SourceMemberMethodSymbol.cs (2)
822Interlocked.CompareExchange(ref _lazyThisParameter, new ThisParameterSymbol(this), null); 843Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
286bagCreatedOnThisThread = Interlocked.CompareExchange(ref lazyCustomAttributesBag, attributesBag, null) == null;
Symbols\Source\SourceModuleSymbol.cs (1)
202if (Interlocked.CompareExchange(ref _globalNamespace, globalNS, null) == null)
Symbols\Source\SourceNamedTypeSymbol_Bases.cs (2)
51if (ReferenceEquals(Interlocked.CompareExchange(ref _lazyBaseType, acyclicBase, ErrorTypeSymbol.UnknownResultType), ErrorTypeSymbol.UnknownResultType)) 260if (Interlocked.CompareExchange(ref _lazyDeclaredBases, MakeDeclaredBases(basesBeingResolved, diagnostics), null) == null)
Symbols\Source\SourceNamedTypeSymbol_Enum.cs (2)
31if ((object)Interlocked.CompareExchange(ref _lazyEnumUnderlyingType, this.GetEnumUnderlyingType(diagnostics), ErrorTypeSymbol.UnknownResultType) == 97Interlocked.CompareExchange(ref _lazyEnumValueField, new SynthesizedEnumValueFieldSymbol(this), null);
Symbols\Source\SourceNamespaceSymbol.AliasesAndUsings.cs (5)
377Interlocked.CompareExchange(ref _lazyMergedGlobalAliasesAndUsings, 456Interlocked.CompareExchange( 610Interlocked.CompareExchange(ref usings, result, null); 902Interlocked.CompareExchange(ref _lazyImports, 1138Interlocked.CompareExchange(ref _lazyImports,
Symbols\Source\SourceNamespaceSymbol.cs (2)
229if (Interlocked.CompareExchange(ref _nameToMembersMap, MakeNameToMembersMap(diagnostics), null) == null) 254Interlocked.CompareExchange(
Symbols\Source\SourcePropertySymbolBase.cs (6)
769Interlocked.CompareExchange(ref _lazyMergedBackingField, backingField, null); 782Interlocked.CompareExchange(ref _lazyDeclaredBackingField, CreateBackingField(), null); 790Interlocked.CompareExchange(ref _lazyMergedBackingField, backingField, null); 1192Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null); 1218Interlocked.CompareExchange(ref _lazySynthesizedSealedAccessor, MakeSynthesizedSealedAccessor(), null); 1299bagCreatedOnThisThread = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null;
Symbols\Source\SourceTypeParameterSymbol.cs (4)
196lazyAttributesStored = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null; 231if (ReferenceEquals(Interlocked.CompareExchange(ref _lazyBounds, bounds, TypeParameterBounds.Unset), TypeParameterBounds.Unset)) 797Interlocked.CompareExchange(ref _lazyTypeMap, typeMap, null); 811Interlocked.CompareExchange(ref _lazyOverriddenMethod, this.GetOverriddenMethod(_overridingMethod), ErrorMethodSymbol.UnknownMethod);
Symbols\SubstitutedEventSymbol.cs (2)
31Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null); 122Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
Symbols\SubstitutedFieldSymbol.cs (1)
32Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null);
Symbols\SubstitutedMethodSymbol.cs (3)
114var prevMap = Interlocked.CompareExchange(ref _lazyMap, newMap, null); 235Interlocked.CompareExchange(ref _lazyReturnType, new TypeWithAnnotations.Boxed(returnType), null); 296Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
Symbols\SubstitutedNamedTypeSymbol.cs (2)
110var prevMap = Interlocked.CompareExchange(ref _lazyMap, newMap, null); 167Interlocked.CompareExchange(ref _lazyBaseType, baseType, ErrorTypeSymbol.UnknownResultType);
Symbols\SubstitutedPropertySymbol.cs (2)
32Interlocked.CompareExchange(ref _lazyType, new TypeWithAnnotations.Boxed(type), null); 140Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
Symbols\Symbol.cs (1)
1811Interlocked.CompareExchange(ref _lazyISymbol, CreateISymbol(), null);
Symbols\Symbol_Attributes.cs (2)
329Interlocked.CompareExchange(ref lazyCustomAttributesBag, new CustomAttributesBag<CSharpAttributeData>(), null); 396Interlocked.CompareExchange(ref lazyCustomAttributesBag, CustomAttributesBag<CSharpAttributeData>.WithEmptyData(), null);
Symbols\Synthesized\GeneratedLabelSymbol.cs (1)
40int seq = System.Threading.Interlocked.Add(ref s_sequence, 1);
Symbols\Synthesized\Records\SynthesizedPrimaryConstructor.cs (1)
136Interlocked.CompareExchange(ref _capturedParameters, Binder.CapturedParametersFinder.GetCapturedParameters(this), null);
Symbols\Synthesized\SynthesizedInstanceMethodSymbol.cs (1)
51Interlocked.CompareExchange(ref _lazyThisParameter, new ThisParameterSymbol(this), null);
Symbols\Synthesized\SynthesizedLocal.cs (1)
203private readonly int _sequence = System.Threading.Interlocked.Increment(ref _nextSequence);
Symbols\Synthesized\SynthesizedSimpleProgramEntryPointSymbol.cs (1)
247if (Interlocked.CompareExchange(ref weakBinder, new WeakReference<ExecutableCodeBinder>(newBinder), previousWeakReference) == previousWeakReference)
Symbols\Tuples\TupleTypeSymbol.cs (1)
543Interlocked.CompareExchange(ref _lazyTupleData, new TupleExtraData(this), null);
Symbols\TypeSymbol.cs (6)
74return Interlocked.CompareExchange(ref _implementationForInterfaceMemberMap, map, null) ?? map; 116return Interlocked.CompareExchange(ref _lazyInterfaceInfo, info, null) ?? info; 393Interlocked.CompareExchange(ref info.interfacesAndTheirBaseInterfaces, MakeInterfacesAndTheirBaseInterfaces(this.InterfacesNoUseSiteDiagnostics()), null); 2272Interlocked.CompareExchange(ref info.explicitInterfaceImplementationMap, MakeExplicitInterfaceImplementationMap(), null); 2314Interlocked.CompareExchange(ref info.synthesizedMethodImplMap, makeSynthesizedMethodImplMap(), null); 2379Interlocked.CompareExchange(ref _lazyAbstractMembers, ComputeAbstractMembers(), null);
Symbols\TypeWithAnnotations.cs (2)
983Interlocked.CompareExchange(ref _resolved, value: (int)getResolvedAnnotationCore(), comparand: Unresolved); 1205Interlocked.CompareExchange(ref _resolved, resolved, null);
Syntax\CSharpSyntaxNode.cs (1)
77Interlocked.CompareExchange(ref node._syntaxTree, CSharpSyntaxTree.CreateWithoutClone(node), null);
Syntax\CSharpSyntaxTree.cs (2)
631Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null); 707Interlocked.CompareExchange(ref _lazyPragmaWarningStateMap, new CSharpPragmaWarningStateMap(this), null);
Syntax\CSharpSyntaxTree.LazySyntaxTree.cs (1)
73Interlocked.CompareExchange(ref _lazyRoot, root, null);
Syntax\CSharpSyntaxTree.ParsedSyntaxTree.cs (1)
66Interlocked.CompareExchange(ref _lazyText, this.GetRoot(cancellationToken).GetText(_encodingOpt, _checksumAlgorithm), null);
Syntax\SyntaxTokenParser.cs (1)
36var lexer = Interlocked.CompareExchange(ref _lexer!, null, _lexer);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\NullableImpactingSpanWalker.cs (1)
39Interlocked.CompareExchange(ref _spans, ImmutableArray.CreateBuilder<TextSpan>(), null);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Completion\CompletionServiceTests.cs (1)
202var generator = new CallbackGenerator(onInit: _ => { }, onExecute: _ => Interlocked.Increment(ref generatorRanCount));
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (232)
Semantics\PrimaryConstructorTests.cs (134)
3773Interlocked.Increment(ref FireCount0); 3777Interlocked.Increment(ref FireCount1); 3781Interlocked.Increment(ref FireCount2); 3786Interlocked.Increment(ref FireCount3); 3790Interlocked.Increment(ref FireCount4); 3794Interlocked.Increment(ref FireCount5); 3812Interlocked.Increment(ref FireCount15); 3816Interlocked.Increment(ref FireCount16); 3820Interlocked.Increment(ref FireCount6); 3838Interlocked.Increment(ref FireCount7); 3851Interlocked.Increment(ref FireCount8); 3865Interlocked.Increment(ref FireCount9); 3887Interlocked.Increment(ref FireCount11); 3890Interlocked.Increment(ref FireCount12); 3893Interlocked.Increment(ref FireCount13); 3917Interlocked.Increment(ref FireCount18); 3921Interlocked.Increment(ref FireCount19); 3931Interlocked.Increment(ref FireCount24); 3935Interlocked.Increment(ref FireCount25); 3939Interlocked.Increment(ref FireCount26); 3955Interlocked.Increment(ref FireCount20); 3958Interlocked.Increment(ref FireCount21); 3961Interlocked.Increment(ref FireCount22); 3972Interlocked.Increment(ref FireCount23); 3996Interlocked.Increment(ref FireCount27); 4000Interlocked.Increment(ref FireCount28); 4004Interlocked.Increment(ref FireCount29); 4022Interlocked.Increment(ref FireCount30); 4026Interlocked.Increment(ref FireCount31); 4090Interlocked.Increment(ref FireCount1); 4093Interlocked.Increment(ref FireCount3); 4096Interlocked.Increment(ref FireCount4); 4099Interlocked.Increment(ref FireCount5); 4102Interlocked.Increment(ref FireCount6); 4105Interlocked.Increment(ref FireCount7); 4176Interlocked.Increment(ref FireCount1); 4180Interlocked.Increment(ref FireCount3); 4183Interlocked.Increment(ref FireCount4); 4187Interlocked.Increment(ref FireCount5); 4190Interlocked.Increment(ref FireCount9); 4198Interlocked.Increment(ref FireCount10); 4214Interlocked.Increment(ref FireCount6); 4220Interlocked.Increment(ref FireCount8); 4226Interlocked.Increment(ref FireCount11); 4235Interlocked.Increment(ref FireCount12); 4327Interlocked.Increment(ref FireCount1); 4331Interlocked.Increment(ref FireCount2); 4335Interlocked.Increment(ref FireCount3); 4349Interlocked.Increment(ref FireCount4); 4364Interlocked.Increment(ref FireCount5); 4390Interlocked.Increment(ref FireCount6); 4394Interlocked.Increment(ref FireCount7); 4398Interlocked.Increment(ref FireCount8); 4402Interlocked.Increment(ref FireCount9); 4406Interlocked.Increment(ref FireCount10); 4410Interlocked.Increment(ref FireCount11); 4414Interlocked.Increment(ref FireCount12); 4418Interlocked.Increment(ref FireCount13); 4422Interlocked.Increment(ref FireCount17); 4436Interlocked.Increment(ref FireCount14); 4440Interlocked.Increment(ref FireCount15); 4444Interlocked.Increment(ref FireCount16); 4512Interlocked.Increment(ref FireCount1); 4523Interlocked.Increment(ref FireCount2); 4537Interlocked.Increment(ref FireCount3); 4553Interlocked.Increment(ref FireCount4); 4646Interlocked.Increment(ref FireCount100); 4659Interlocked.Increment(ref FireCount200); 4675Interlocked.Increment(ref FireCount300); 4693Interlocked.Increment(ref FireCount400); 4720Interlocked.Increment(ref FireCount1000); 4731Interlocked.Increment(ref FireCount2000); 4745Interlocked.Increment(ref FireCount3000); 4761Interlocked.Increment(ref FireCount4000); 4830Interlocked.Increment(ref FireCount1); 4841Interlocked.Increment(ref FireCount2); 4852Interlocked.Increment(ref FireCount3); 4863Interlocked.Increment(ref FireCount4); 4975Interlocked.Increment(ref FireCount100); 4986Interlocked.Increment(ref FireCount200); 4997Interlocked.Increment(ref FireCount300); 5008Interlocked.Increment(ref FireCount400); 5043Interlocked.Increment(ref FireCount1000); 5054Interlocked.Increment(ref FireCount2000); 5065Interlocked.Increment(ref FireCount3000); 5076Interlocked.Increment(ref FireCount4000); 5152Interlocked.Increment(ref FireCount1); 5155Interlocked.Increment(ref FireCount2); 5158Interlocked.Increment(ref FireCount3); 5161Interlocked.Increment(ref FireCount4); 5184Interlocked.Increment(ref FireCount7); 5187Interlocked.Increment(ref FireCount8); 5190Interlocked.Increment(ref FireCount9); 5275Interlocked.Increment(ref FireCount0); 5279Interlocked.Increment(ref FireCount7); 5283Interlocked.Increment(ref FireCount12); 5301Interlocked.Increment(ref FireCount3); 5319Interlocked.Increment(ref FireCountThisConstructorInitializer); 5332Interlocked.Increment(ref FireCountConstructorDeclaration); 5349Interlocked.Increment(ref FireCountStructDeclarationA); 5366Interlocked.Increment(ref FireCount5); 5382Interlocked.Increment(ref FireCountSimpleBaseTypeI1onA); 5406Interlocked.Increment(ref FireCountParameterListAPrimaryCtor); 5410Interlocked.Increment(ref FireCountStringParameterList); 5428Interlocked.Increment(ref FireCount11); 5493Interlocked.Increment(ref FireCount1); 5496Interlocked.Increment(ref FireCount3); 5499Interlocked.Increment(ref FireCount4); 5502Interlocked.Increment(ref FireCount5); 5505Interlocked.Increment(ref FireCount6); 5508Interlocked.Increment(ref FireCount7); 5580Interlocked.Increment(ref FireCount1); 5584Interlocked.Increment(ref FireCount3); 5587Interlocked.Increment(ref FireCount4); 5591Interlocked.Increment(ref FireCount5); 5594Interlocked.Increment(ref FireCount9); 5602Interlocked.Increment(ref FireCount10); 5618Interlocked.Increment(ref FireCount6); 5624Interlocked.Increment(ref FireCount8); 5630Interlocked.Increment(ref FireCount11); 5639Interlocked.Increment(ref FireCount12); 5695Interlocked.Increment(ref FireCount1); 5717Interlocked.Increment(ref FireCount6); 5721Interlocked.Increment(ref FireCount7); 5735Interlocked.Increment(ref FireCount14); 5787Interlocked.Increment(ref FireCount1); 5849Interlocked.Increment(ref FireCount1); 5860Interlocked.Increment(ref FireCount4); 5941Interlocked.Increment(ref FireCount100); 5952Interlocked.Increment(ref FireCount400); 5963Interlocked.Increment(ref FireCount500); 5999Interlocked.Increment(ref FireCount1000); 6010Interlocked.Increment(ref FireCount4000); 6021Interlocked.Increment(ref FireCount5000);
Semantics\RecordTests.cs (98)
26258Interlocked.Increment(ref FireCount0); 26262Interlocked.Increment(ref FireCount1); 26266Interlocked.Increment(ref FireCount2); 26271Interlocked.Increment(ref FireCount3); 26275Interlocked.Increment(ref FireCount4); 26279Interlocked.Increment(ref FireCount5); 26297Interlocked.Increment(ref FireCount15); 26301Interlocked.Increment(ref FireCount16); 26305Interlocked.Increment(ref FireCount6); 26323Interlocked.Increment(ref FireCount7); 26336Interlocked.Increment(ref FireCount8); 26350Interlocked.Increment(ref FireCount9); 26372Interlocked.Increment(ref FireCount11); 26375Interlocked.Increment(ref FireCount12); 26378Interlocked.Increment(ref FireCount13); 26398Interlocked.Increment(ref FireCount18); 26402Interlocked.Increment(ref FireCount19); 26412Interlocked.Increment(ref FireCount24); 26416Interlocked.Increment(ref FireCount25); 26420Interlocked.Increment(ref FireCount26); 26436Interlocked.Increment(ref FireCount20); 26439Interlocked.Increment(ref FireCount21); 26442Interlocked.Increment(ref FireCount22); 26453Interlocked.Increment(ref FireCount23); 26477Interlocked.Increment(ref FireCount27); 26481Interlocked.Increment(ref FireCount28); 26485Interlocked.Increment(ref FireCount29); 26503Interlocked.Increment(ref FireCount30); 26507Interlocked.Increment(ref FireCount31); 26573Interlocked.Increment(ref FireCount1); 26576Interlocked.Increment(ref FireCount2); 26579Interlocked.Increment(ref FireCount3); 26582Interlocked.Increment(ref FireCount4); 26585Interlocked.Increment(ref FireCount5); 26588Interlocked.Increment(ref FireCount6); 26591Interlocked.Increment(ref FireCount7); 26668Interlocked.Increment(ref FireCount1); 26672Interlocked.Increment(ref FireCount2); 26676Interlocked.Increment(ref FireCount3); 26679Interlocked.Increment(ref FireCount4); 26683Interlocked.Increment(ref FireCount5); 26686Interlocked.Increment(ref FireCount9); 26696Interlocked.Increment(ref FireCount10); 26714Interlocked.Increment(ref FireCount6); 26720Interlocked.Increment(ref FireCount7); 26726Interlocked.Increment(ref FireCount8); 26732Interlocked.Increment(ref FireCount11); 26743Interlocked.Increment(ref FireCount12); 26835Interlocked.Increment(ref FireCount1); 26839Interlocked.Increment(ref FireCount2); 26843Interlocked.Increment(ref FireCount3); 26857Interlocked.Increment(ref FireCount4); 26872Interlocked.Increment(ref FireCount5); 26898Interlocked.Increment(ref FireCount6); 26902Interlocked.Increment(ref FireCount7); 26906Interlocked.Increment(ref FireCount8); 26910Interlocked.Increment(ref FireCount9); 26914Interlocked.Increment(ref FireCount10); 26918Interlocked.Increment(ref FireCount11); 26922Interlocked.Increment(ref FireCount12); 26926Interlocked.Increment(ref FireCount13); 26930Interlocked.Increment(ref FireCount17); 26944Interlocked.Increment(ref FireCount14); 26948Interlocked.Increment(ref FireCount15); 26952Interlocked.Increment(ref FireCount16); 27020Interlocked.Increment(ref FireCount1); 27031Interlocked.Increment(ref FireCount2); 27045Interlocked.Increment(ref FireCount3); 27061Interlocked.Increment(ref FireCount4); 27154Interlocked.Increment(ref FireCount100); 27167Interlocked.Increment(ref FireCount200); 27183Interlocked.Increment(ref FireCount300); 27201Interlocked.Increment(ref FireCount400); 27228Interlocked.Increment(ref FireCount1000); 27239Interlocked.Increment(ref FireCount2000); 27253Interlocked.Increment(ref FireCount3000); 27269Interlocked.Increment(ref FireCount4000); 27338Interlocked.Increment(ref FireCount1); 27349Interlocked.Increment(ref FireCount2); 27360Interlocked.Increment(ref FireCount3); 27371Interlocked.Increment(ref FireCount4); 27483Interlocked.Increment(ref FireCount100); 27494Interlocked.Increment(ref FireCount200); 27505Interlocked.Increment(ref FireCount300); 27516Interlocked.Increment(ref FireCount400); 27551Interlocked.Increment(ref FireCount1000); 27562Interlocked.Increment(ref FireCount2000); 27573Interlocked.Increment(ref FireCount3000); 27584Interlocked.Increment(ref FireCount4000); 27664Interlocked.Increment(ref FireCount1); 27667Interlocked.Increment(ref FireCount2); 27670Interlocked.Increment(ref FireCount3); 27673Interlocked.Increment(ref FireCount4); 27686Interlocked.Increment(ref FireCount5); 27689Interlocked.Increment(ref FireCount6); 27702Interlocked.Increment(ref FireCount7); 27705Interlocked.Increment(ref FireCount8); 27708Interlocked.Increment(ref FireCount9);
Microsoft.CodeAnalysis.CSharp.Features (3)
Completion\CSharpCompletionService.cs (1)
64Interlocked.Exchange(ref _latestRules, newRules);
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (1)
67Interlocked.CompareExchange(ref _diagnostics, ImmutableArray.CreateBuilder<Diagnostic>(), null);
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\NullableImpactingSpanWalker.cs (1)
39Interlocked.CompareExchange(ref _spans, ImmutableArray.CreateBuilder<TextSpan>(), null);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (97)
Semantics\RecordStructTests.cs (53)
5974Interlocked.Increment(ref FireCount0); 5978Interlocked.Increment(ref FireCount7); 5982Interlocked.Increment(ref FireCount12); 6000Interlocked.Increment(ref FireCount3); 6018Interlocked.Increment(ref FireCountThisConstructorInitializer); 6031Interlocked.Increment(ref FireCountConstructorDeclaration); 6048Interlocked.Increment(ref FireCountRecordStructDeclarationA); 6065Interlocked.Increment(ref FireCount5); 6081Interlocked.Increment(ref FireCountSimpleBaseTypeI1onA); 6105Interlocked.Increment(ref FireCountParameterListAPrimaryCtor); 6109Interlocked.Increment(ref FireCountStringParameterList); 6127Interlocked.Increment(ref FireCount11); 6194Interlocked.Increment(ref FireCount1); 6197Interlocked.Increment(ref FireCount2); 6200Interlocked.Increment(ref FireCount3); 6203Interlocked.Increment(ref FireCount4); 6206Interlocked.Increment(ref FireCount5); 6209Interlocked.Increment(ref FireCount6); 6212Interlocked.Increment(ref FireCount7); 6290Interlocked.Increment(ref FireCount1); 6294Interlocked.Increment(ref FireCount2); 6298Interlocked.Increment(ref FireCount3); 6301Interlocked.Increment(ref FireCount4); 6305Interlocked.Increment(ref FireCount5); 6308Interlocked.Increment(ref FireCount9); 6318Interlocked.Increment(ref FireCount10); 6336Interlocked.Increment(ref FireCount6); 6342Interlocked.Increment(ref FireCount7); 6348Interlocked.Increment(ref FireCount8); 6354Interlocked.Increment(ref FireCount11); 6365Interlocked.Increment(ref FireCount12); 6421Interlocked.Increment(ref FireCount1); 6443Interlocked.Increment(ref FireCount6); 6447Interlocked.Increment(ref FireCount7); 6461Interlocked.Increment(ref FireCount14); 6513Interlocked.Increment(ref FireCount1); 6575Interlocked.Increment(ref FireCount1); 6586Interlocked.Increment(ref FireCount4); 6667Interlocked.Increment(ref FireCount100); 6678Interlocked.Increment(ref FireCount400); 6689Interlocked.Increment(ref FireCount500); 6725Interlocked.Increment(ref FireCount1000); 6736Interlocked.Increment(ref FireCount4000); 6747Interlocked.Increment(ref FireCount5000); 6827Interlocked.Increment(ref FireCount1); 6830Interlocked.Increment(ref FireCount2); 6833Interlocked.Increment(ref FireCount3); 6836Interlocked.Increment(ref FireCount4); 6849Interlocked.Increment(ref FireCount5); 6852Interlocked.Increment(ref FireCount6); 6865Interlocked.Increment(ref FireCount7); 6868Interlocked.Increment(ref FireCount8); 6871Interlocked.Increment(ref FireCount9);
Semantics\TopLevelStatementsTests.cs (43)
6444Interlocked.Increment(ref FireCount1); 6447Interlocked.Increment(ref FireCount2); 6474Interlocked.Increment(ref FireCount3); 6477Interlocked.Increment(ref FireCount4); 6540Interlocked.Increment(ref FireCount1); 6543Interlocked.Increment(ref FireCount2); 6616Interlocked.Increment(ref FireCount1); 6620Interlocked.Increment(ref FireCount2); 6632Interlocked.Increment(ref FireCount3); 6640Interlocked.Increment(ref FireCount4); 6643Interlocked.Increment(ref FireCount5); 6655Interlocked.Increment(ref FireCount6); 6662Interlocked.Increment(ref FireCount7); 6669Interlocked.Increment(ref FireCount8); 6728Interlocked.Increment(ref FireCount1); 6731Interlocked.Increment(ref FireCount2); 6748Interlocked.Increment(ref FireCount3); 6751Interlocked.Increment(ref FireCount4); 6806Interlocked.Increment(ref FireCount1); 6809Interlocked.Increment(ref FireCount2); 6864Interlocked.Increment(ref FireCount1); 6867Interlocked.Increment(ref FireCount2); 6922Interlocked.Increment(ref FireCount1); 6925Interlocked.Increment(ref FireCount2); 6990Interlocked.Increment(ref FireCount1); 6993Interlocked.Increment(ref FireCount2); 7072Interlocked.Increment(ref FireCount1); 7077Interlocked.Increment(ref FireCount2); 7106Interlocked.Increment(ref FireCount3); 7186Interlocked.Increment(ref FireCount1); 7191Interlocked.Increment(ref FireCount2); 7196Interlocked.Increment(ref FireCount3); 7211Interlocked.Increment(ref FireCount4); 7276Interlocked.Increment(ref FireCount1); 7282Interlocked.Increment(ref FireCount2); 7291Interlocked.Increment(ref FireCount3); 7294Interlocked.Increment(ref FireCount4); 7346Interlocked.Increment(ref FireCount3); 7358Interlocked.Increment(ref FireCount1); 7361Interlocked.Increment(ref FireCount2); 7413Interlocked.Increment(ref FireCount3); 7426Interlocked.Increment(ref FireCount1); 7429Interlocked.Increment(ref FireCount2);
SourceGeneration\GeneratorDriverTests.cs (1)
193Interlocked.Increment(ref GeneratedClassCount);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (2)
Symbols\Source\NullablePublicAPITests.cs (2)
1798Interlocked.Increment(ref HitCount); 4854Interlocked.Increment(ref HitCount);
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.ParsedSyntaxTree.cs (1)
49Interlocked.CompareExchange(ref _lazyText, GetRoot(cancellationToken).GetText(Encoding, _checksumAlgorithm), null);
Microsoft.CodeAnalysis.EditorFeatures (10)
CodeActions\IUIThreadOperationContextExtensions.cs (4)
32Interlocked.Exchange(ref _totalItems, 0); 33Interlocked.Exchange(ref _completedItems, 0); 38Interlocked.Add(ref _totalItems, value.IncompleteItemsValue.Value); 41Interlocked.Add(ref _completedItems, value.CompleteItemValue.Value);
EditAndContinue\ActiveStatementTrackingService.cs (2)
72if (Interlocked.CompareExchange(ref _session, newSession, null) != null) 86var session = Interlocked.Exchange(ref _session, null);
EditAndContinue\EditAndContinueLanguageService.cs (2)
207var committedDesignTimeSolution = Interlocked.Exchange(ref _pendingUpdatedDesignTimeSolution, null); 238Contract.ThrowIfNull(Interlocked.Exchange(ref _pendingUpdatedDesignTimeSolution, null));
Tagging\AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs (2)
56var oldTagTrees = Interlocked.Exchange( 256if (oldTagTrees != Interlocked.CompareExchange(ref _cachedTagTrees_mayChangeFromAnyThread, newTagTrees, oldTagTrees))
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (2)
BlindAggregatorFactory.cs (2)
160=> unchecked((uint)Interlocked.Increment(ref pThis->_refCount)); 164var result = unchecked((uint)Interlocked.Decrement(ref pThis->_refCount));
Microsoft.CodeAnalysis.EditorFeatures.Wpf (2)
Adornments\GraphicsResult.cs (1)
23=> Interlocked.Exchange(ref _dispose, null)?.Invoke();
QuickInfo\DisposableToolTip.cs (1)
26=> Interlocked.Exchange(ref _workspaceOpt, null)?.Dispose();
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (2)
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.Utilities (4)
Debugger\Engine\DkmClrModuleInstance.cs (1)
52Interlocked.Increment(ref _resolveTypeNameFailures);
Debugger\Engine\DkmClrType.cs (1)
131Interlocked.CompareExchange(ref _lazyGenericArguments, genericArgs, null);
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
Microsoft.CodeAnalysis.Features (15)
Completion\CompletionDescription.cs (1)
68Interlocked.CompareExchange(ref _text, string.Concat(TaggedParts.Select(p => p.Text)), null);
Completion\CompletionService.ProviderManager.cs (1)
77Interlocked.CompareExchange(ref _lazyImportedProviders, providers, null);
Debugging\DebugInformationReaderProvider.cs (1)
92var symReader = Interlocked.Exchange(ref _symReader, null);
EditAndContinue\DebuggingSession.cs (4)
151if (Interlocked.Exchange(ref _pendingUpdate, null) != null) 165var previousPendingUpdate = Interlocked.Exchange(ref _pendingUpdate, update); 176var pendingUpdate = Interlocked.Exchange(ref _pendingUpdate, null); 487var updateId = new UpdateId(Id, Interlocked.Increment(ref _updateOrdinal));
EditAndContinue\EditAndContinueService.cs (1)
166var sessionId = new DebuggingSessionId(Interlocked.Increment(ref s_debuggingSessionId));
EditAndContinue\SolutionSnapshotRegistry.cs (1)
41var id = new SolutionSnapshotId(Interlocked.Increment(ref s_solutionSnapshotId));
EditAndContinue\TraceLog.cs (1)
231var index = Interlocked.Increment(ref _currentLine);
ExternalAccess\UnitTesting\SolutionCrawler\UnitTestingSolutionCrawlerProgressReporter.cs (2)
69if (start ? (Interlocked.Increment(ref referenceCount) == 1) : (Interlocked.Decrement(ref referenceCount) == 0))
NavigateTo\NavigateToSearcher.cs (2)
119Interlocked.Add(ref _remainingProgressItems, count); 126var newValue = Interlocked.Add(ref _remainingProgressItems, -count);
QuickInfo\QuickInfoSection.cs (1)
57Interlocked.CompareExchange(ref _text, string.Concat(TaggedParts.Select(t => t.Text)), null);
Microsoft.CodeAnalysis.Features.UnitTests (1)
EditAndContinue\CompileTimeSolutionProviderTests.cs (1)
95Interlocked.Increment(ref generatorInvocations);
Microsoft.CodeAnalysis.InteractiveHost (7)
Interactive\Core\InteractiveHost.cs (4)
125Interlocked.Exchange(ref _lazyRemoteService, null)?.Dispose(); 190return new LazyRemoteService(this, options, Interlocked.Increment(ref _remoteServiceInstanceId), skipInitialization); 240var previousService = Interlocked.CompareExchange(ref _lazyRemoteService, newService, currentRemoteService); 338var oldService = Interlocked.Exchange(ref _lazyRemoteService, newService);
src\Compilers\Core\Portable\InternalUtilities\SemaphoreSlimExtensions.cs (1)
47var semaphoreToDispose = Interlocked.Exchange(ref _semaphore, null);
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
Microsoft.CodeAnalysis.LanguageServer (4)
HostWorkspace\LanguageServerProjectSystem.cs (3)
37/// The suffix to use for the binary log name; incremented each time we have a new build. Should be incremented with <see cref="Interlocked.Increment(ref int)"/>. 149var shouldShowToast = Interlocked.CompareExchange(ref _displayedToast, value: 1, comparand: 0) == 0; 205var numericSuffix = Interlocked.Increment(ref _binaryLogNumericSuffix);
ServerConfigurationFactory.cs (1)
68Interlocked.Exchange(ref _currentLogLevel, (int)level);
Microsoft.CodeAnalysis.LanguageServer.Protocol (6)
Features\CodeFixes\CodeFixService.cs (2)
361Interlocked.CompareExchange(ref _lazyWorkspaceFixersMap, workspaceFixersMap, null); 387Interlocked.CompareExchange(ref _lazyFixerPriorityMap, fixersPriorityByLanguageMap, null);
Features\Diagnostics\DocumentAnalysisExecutor.cs (2)
258Interlocked.CompareExchange(ref _lazySyntaxDiagnostics, syntaxDiagnostics, null); 294Interlocked.CompareExchange(ref _lazySemanticDiagnostics, semanticDiagnostics, null);
Handler\Diagnostics\DiagnosticsRefreshQueue.cs (1)
66Interlocked.Increment(ref _globalStateVersion);
Handler\PullHandlers\VersionedPullCache.cs (1)
90return Interlocked.Increment(ref _nextDocumentResultId);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (1)
Diagnostics\DiagnosticsPullCacheTests.cs (1)
122Interlocked.Increment(ref provider.DiagnosticsRequestedCount);
Microsoft.CodeAnalysis.PooledObjects.Package (2)
ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
Microsoft.CodeAnalysis.Remote.ServiceHub (3)
Host\IGlobalServiceBroker.cs (1)
38Interlocked.CompareExchange(ref s_instance, serviceBroker, null);
Services\BrokeredServiceBase.FactoryBase.cs (1)
66if (Interlocked.CompareExchange(ref s_cultureInitialized, 1, 0) == 0)
src\VisualStudio\Core\Def\Watson\FaultReporter.cs (1)
148if (Interlocked.Increment(ref s_dumpsSubmitted) <= 3)
Microsoft.CodeAnalysis.Remote.Workspaces (2)
EditAndContinue\ManagedHotReloadLanguageService.cs (2)
143var committedDesignTimeSolution = Interlocked.Exchange(ref _pendingUpdatedDesignTimeSolution, null); 197Contract.ThrowIfNull(Interlocked.Exchange(ref _pendingUpdatedDesignTimeSolution, null));
Microsoft.CodeAnalysis.Scripting (5)
Script.cs (2)
150Interlocked.CompareExchange(ref _lazyCompilation, compilation, null); 392Interlocked.CompareExchange(ref _lazyExecutor, Builder.CreateExecutor<T>(Compiler, GetCompilation(), Options.EmitDebugInformation, cancellationToken), null);
ScriptBuilder.cs (2)
64_assemblyNamePrefix = s_globalAssemblyNamePrefix + "#" + Interlocked.Increment(ref s_engineIdDispenser).ToString(); 70int id = Interlocked.Increment(ref _submissionIdDispenser);
ScriptExecutionState.cs (1)
43var wasAlreadyFrozen = Interlocked.CompareExchange(ref _frozen, 1, 0) == 1;
Microsoft.CodeAnalysis.Test.Utilities (6)
Compilation\IRuntimeEnvironment.cs (1)
311Interlocked.Increment(ref s_dumpCount);
Diagnostics\CommonDiagnosticAnalyzers.cs (1)
1165var myToken = Interlocked.Increment(ref _token);
Metadata\ILValidation.cs (4)
198Interlocked.CompareExchange( 214Interlocked.CompareExchange( 229Interlocked.CompareExchange( 249Interlocked.CompareExchange(
Microsoft.CodeAnalysis.UnitTests (1)
MetadataReferences\FusionAssemblyPortabilityPolicy.cs (1)
75IntPtr ptr = Interlocked.Exchange(ref _assemblyConfigCookie, IntPtr.Zero);
Microsoft.CodeAnalysis.VisualBasic (167)
Analysis\FlowAnalysis\ControlFlowAnalysis.vb (2)
98Interlocked.CompareExchange(_regionStartPointIsReachable, startPointIsReachable, Nothing) 99Interlocked.CompareExchange(_regionEndPointIsReachable, endPointIsReachable, Nothing)
Analysis\FlowAnalysis\VisualBasicDataFlowAnalysis.vb (1)
63Interlocked.CompareExchange(_unassignedVariables, result, Nothing)
Binding\Binder_Lambda.vb (1)
867Interlocked.CompareExchange(source.BindingCache.ErrorRecoverySignature,
Binding\Binder_WithBlock.vb (3)
155Dim oldValue = Interlocked.CompareExchange(Me._exprAccessedFromNestedLambda, ThreeState.True, ThreeState.Unknown) 172Dim oldValue = Interlocked.CompareExchange(Me._exprHasByRefMeReference, newValue, ThreeState.Unknown) 247Interlocked.CompareExchange(Me._withBlockInfo,
Binding\BlockBaseBinder.vb (1)
39Interlocked.CompareExchange(Me._lazyLocalsMap, BuildMap(Me.Locals), Nothing)
Binding\DescendantBinderFactory.vb (2)
87Interlocked.CompareExchange(_lazyNodeToBinderMap, builder.NodeToBinderMap, Nothing) 88Interlocked.CompareExchange(_lazyStmtListToBinderMap, builder.StmtListToBinderMap, Nothing)
Binding\DocumentationCommentCrefBinder.vb (1)
29Interlocked.CompareExchange(Me._typeParameterBinder, New TypeParametersBinder(Me, typeParameters), Nothing)
Binding\ExecutableCodeBinder.vb (1)
79Interlocked.CompareExchange(Me._labelsMap, BuildLabelsMap(Me.Labels), Nothing)
Binding\ImplicitVariableBinder.vb (1)
249Interlocked.CompareExchange(_threadIdForDeclaration, Environment.CurrentManagedThreadId, -1)
BoundTree\BoundMethodGroup.vb (2)
81Interlocked.CompareExchange(_lazyUseSiteDiagnostics, localUseSiteInfo.Diagnostics, Nothing) 82Interlocked.CompareExchange(_lazyUseSiteDependencies, If(localUseSiteInfo.AccumulatesDependencies, localUseSiteInfo.Dependencies, Nothing), Nothing)
BoundTree\UnboundLambda.vb (1)
105Interlocked.CompareExchange(_BindingCache.AnonymousDelegate,
Compilation\VisualBasicCompilation.vb (6)
257Interlocked.CompareExchange(_lazyMyTemplate, tree, VisualBasicSyntaxTree.Dummy) 276If Interlocked.CompareExchange(_lazyMyTemplate, tree, VisualBasicSyntaxTree.Dummy) Is VisualBasicSyntaxTree.Dummy Then 308Interlocked.CompareExchange(_lazyEmbeddedSymbolManager, New EmbeddedSymbolManager(embedded), Nothing) 1445Interlocked.CompareExchange(_lazyGlobalNamespace, MergedNamespaceSymbol.CreateGlobalNamespace(Me), Nothing) 1510Interlocked.CompareExchange(_lazyEntryPoint, New EntryPoint(entryPoint, diagnostics), Nothing) 1794Interlocked.CompareExchange(_lazyCompilationUnitCompletedTrees, New HashSet(Of SyntaxTree)(), Nothing)
Declarations\DeclarationTable.vb (1)
153Interlocked.CompareExchange(_mergedRoot, CalculateMergedRoot(compilation), Nothing)
Declarations\MergedTypeDeclaration.vb (2)
165Interlocked.CompareExchange(Me._children, MakeChildren(), Nothing) 179Interlocked.CompareExchange(_memberNames, names, Nothing)
DocumentationComments\PEDocumenationCommentUtils.vb (1)
23Interlocked.CompareExchange(lazyDocComment,
DocumentationComments\SourceDocumentationCommentUtils.vb (1)
20Interlocked.CompareExchange(lazyXmlText, xmlText, Nothing)
Emit\EditAndContinue\PEDeltaAssemblyBuilder.vb (1)
320Interlocked.CompareExchange(_lazyHotReloadExceptionType, symbol, comparand:=Nothing)
Emit\NoPia\EmbeddedTypesManager.vb (2)
53If TypeSymbol.Equals(Interlocked.CompareExchange(Of NamedTypeSymbol)(_lazySystemStringType, type, ErrorTypeSymbol.UnknownResultType), ErrorTypeSymbol.UnknownResultType, TypeCompareKind.ConsiderEverything) Then 74If Interlocked.CompareExchange(Of MethodSymbol)(lazyMethod, symbol, ErrorMethodSymbol.UnknownMethod) = ErrorMethodSymbol.UnknownMethod Then
Emit\SymbolTranslator.vb (1)
43Interlocked.CompareExchange(_addedEmbeddedSymbols, New ConcurrentSet(Of Symbol)(ReferenceEqualityComparer.Instance), Nothing)
Emit\SynthesizedStaticLocalBackingFieldAdapter.vb (1)
41Interlocked.CompareExchange(_metadataWriter, metadataWriter, Nothing)
Errors\LazyObsoleteDiagnosticInfo.vb (1)
40Interlocked.CompareExchange(_lazyActualObsoleteDiagnostic, If(info, ErrorFactory.VoidDiagnosticInfo), Nothing)
Symbols\AnonymousTypes\AnonymousTypeManager_Templates.vb (2)
54Interlocked.CompareExchange(Me._concurrentTypesCache, 72Interlocked.CompareExchange(Me._concurrentDelegatesCache,
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousTypeOrDelegateTemplateSymbol.vb (2)
298Dim oldValue = Interlocked.CompareExchange(Me._nameAndIndex, value, Nothing) 356If Interlocked.CompareExchange(Me._adjustedPropertyNames, newAdjustedNames, currentAdjustedNames) Is currentAdjustedNames Then
Symbols\Attributes\PEAttributeData.vb (5)
134Interlocked.CompareExchange(Of KeyValuePair(Of String, TypedConstant)())( 139Interlocked.CompareExchange(Of TypedConstant())( 155Interlocked.CompareExchange(Of NamedTypeSymbol)( 170Interlocked.CompareExchange(Of MethodSymbol)( 175Interlocked.CompareExchange(Of NamedTypeSymbol)(
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.SymbolsCollection.vb (2)
86Interlocked.CompareExchange(_markAllDeferredSymbolsAsReferencedIsCalled, 165Interlocked.CompareExchange(_sealed, 1, 0)
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.vb (3)
57Interlocked.CompareExchange(s_embeddedSyntax, ParseResourceText(EmbeddedResources.Embedded), Nothing) 72Interlocked.CompareExchange(s_vbCoreSyntax, ParseResourceText(EmbeddedResources.VbCoreSourceText), Nothing) 84Interlocked.CompareExchange(s_internalXmlHelperSyntax, ParseResourceText(EmbeddedResources.InternalXmlHelper), Nothing)
Symbols\IndexedTypeParameterSymbol.vb (1)
57Interlocked.CompareExchange(s_parameterPool, newPool, initialPool)
Symbols\MergedNamespaceSymbol.vb (1)
270Interlocked.CompareExchange(_lazyEmbeddedKind, value, EmbeddedSymbolKind.Unset)
Symbols\Metadata\PE\PEAssemblySymbol.vb (2)
284Interlocked.CompareExchange( 308Interlocked.CompareExchange(_lazyObsoleteAttributeData, experimentalData, ObsoleteAttributeData.Uninitialized)
Symbols\Metadata\PE\PEEventSymbol.vb (1)
169Interlocked.CompareExchange(Me._lazyDeclaredAccessibility, DirectCast(accessibility, Integer), s_unsetAccessibility)
Symbols\Metadata\PE\PEFieldSymbol.vb (2)
287Interlocked.CompareExchange(_lazyConstantValue, 381Interlocked.CompareExchange(_lazyType, type, Nothing)
Symbols\Metadata\PE\PEMethodSymbol.vb (1)
845Interlocked.CompareExchange(AccessUncommonFields()._lazyOverloadResolutionPriority, priority, 0)
Symbols\Metadata\PE\PEModuleSymbol.vb (5)
295Interlocked.CompareExchange(_lazyTypeNames, _module.TypeNames.AsCaseInsensitiveCollection(), Nothing) 304Interlocked.CompareExchange(_lazyNamespaceNames, _module.NamespaceNames.AsCaseInsensitiveCollection(), Nothing) 328Interlocked.CompareExchange(_lazySystemTypeSymbol, GetWellKnownType(WellKnownType.System_Type), Nothing) 500Interlocked.CompareExchange( 525Interlocked.CompareExchange(_lazyObsoleteAttributeData, experimentalData, ObsoleteAttributeData.Uninitialized)
Symbols\Metadata\PE\PENamedTypeSymbol.vb (9)
403Interlocked.CompareExchange(_lazyEnumUnderlyingType, 497Interlocked.CompareExchange(Of ICollection(Of String))( 728Dim exchangeResult = Interlocked.CompareExchange(_lazyMembers, membersDict, Nothing) 732Interlocked.Exchange(Of ICollection(Of String))(_lazyMemberNames, memberNames) 789Interlocked.CompareExchange(_lazyNestedTypes, typesDict, Nothing) 945Interlocked.CompareExchange( 957Interlocked.CompareExchange( 1060Interlocked.CompareExchange(_lazyCoClassType, 1088Interlocked.CompareExchange(_lazyDefaultPropertyName, If(memberName, String.Empty), Nothing)
Symbols\Metadata\PE\PENamespaceSymbol.vb (3)
222Interlocked.CompareExchange(m_lazyMembers, members, Nothing) 273Interlocked.CompareExchange(_lazyNoPiaLocalTypes, noPiaLocalTypes, Nothing) 276If Interlocked.CompareExchange(m_lazyTypes, typesDict, Nothing) Is Nothing Then
Symbols\Metadata\PE\PENestedNamespaceSymbol.vb (1)
127Interlocked.Exchange(_typesByNS, Nothing)
Symbols\Metadata\PE\PEParameterSymbol.vb (1)
345Interlocked.CompareExchange(_lazyDefaultValue, defaultValue, ConstantValue.Unset)
Symbols\Metadata\PE\PEPropertySymbol.vb (2)
182Interlocked.CompareExchange(Me._lazyDeclaredAccessibility, GetDeclaredAccessibility(Me), s_unsetAccessibility) 233Interlocked.CompareExchange(_lazyOverloadResolutionPriority, New StrongBox(Of Integer)(priority), Nothing)
Symbols\MetadataOrSourceAssemblySymbol.vb (6)
77Interlocked.CompareExchange(_lazySpecialTypes, 81If (Interlocked.CompareExchange(_lazySpecialTypes(CInt(typeId)), corType, Nothing) IsNot Nothing) Then 86Interlocked.Increment(_cachedSpecialTypes) 107Interlocked.CompareExchange(_lazyTypeNames, UnionCollection(Of String).Create(Me.Modules, Function(m) m.TypeNames), Nothing) 117Interlocked.CompareExchange(_lazyNamespaceNames, UnionCollection(Of String).Create(Me.Modules, Function(m) m.NamespaceNames), Nothing) 172Interlocked.CompareExchange(_assembliesToWhichInternalAccessHasBeenAnalyzed, New ConcurrentDictionary(Of AssemblySymbol, IVTConclusion), Nothing)
Symbols\MissingAssemblySymbol.vb (2)
227Interlocked.CompareExchange(_lazySpecialTypes, New NamedTypeSymbol(InternalSpecialType.NextAvailable - 1) {}, Nothing) 233Interlocked.CompareExchange(_lazySpecialTypes(CInt(type)), corType, Nothing)
Symbols\MissingMetadataTypeSymbol.vb (2)
174Interlocked.CompareExchange(_lazyContainingNamespace, container, Nothing) 194Interlocked.CompareExchange(_lazyTypeId, CInt(typeId), -1)
Symbols\NamedTypeSymbol.vb (1)
768Interlocked.CompareExchange(variable, value, comparand)
Symbols\NonMissingAssemblySymbol.vb (1)
57Interlocked.CompareExchange(_lazyGlobalNamespace, MergedNamespaceSymbol.CreateGlobalNamespace(Me), Nothing)
Symbols\ObsoleteAttributeHelpers.vb (1)
29Interlocked.CompareExchange(data, obsoleteAttributeData, ObsoleteAttributeData.Uninitialized)
Symbols\PEOrSourceOrMergedNamespaceSymbol.vb (1)
94Dim cnt = Interlocked.Increment(Me._extQueryCnt)
Symbols\ReducedExtensionMethodSymbol.vb (2)
398Interlocked.CompareExchange(_lazyReturnType, type, Nothing) 867Interlocked.CompareExchange(_lazyType, paramType, Nothing)
Symbols\Retargeting\RetargetingNamedTypeSymbol.vb (1)
164Interlocked.CompareExchange(_lazyCoClass, coClass, DirectCast(ErrorTypeSymbol.UnknownResultType, TypeSymbol))
Symbols\Source\LocalSymbol.vb (3)
126Interlocked.CompareExchange(_lazyType, ComputeType(), Nothing) 154Interlocked.CompareExchange(_lazyType, type, Nothing) 917Interlocked.CompareExchange(_evaluatedConstant, New EvaluatedConstantInfo(constantValue, type, expression, diagnostics), Nothing)
Symbols\Source\SourceAssemblySymbol.vb (7)
141Interlocked.CompareExchange(m_lazyIdentity, ComputeIdentity(), Nothing) 379Interlocked.CompareExchange(lazyNetModuleAttributesBag, CustomAttributesBag(Of VisualBasicAttributeData).Empty, Nothing) 441Interlocked.CompareExchange(_lazyDuplicateAttributeIndices, attributeIndicesToSkip, Nothing) 983Interlocked.CompareExchange(_lazyInternalsVisibleToMap, 1656Interlocked.CompareExchange(_optimisticallyGrantedInternalsAccess, New ConcurrentDictionary(Of AssemblySymbol, Boolean), Nothing) 1719Interlocked.CompareExchange(_lazyStrongNameKeys, keys, Nothing) 1744Interlocked.CompareExchange(_lazyStrongNameKeys, keys, Nothing)
Symbols\Source\SourceComplexParameterSymbol.vb (2)
98Interlocked.CompareExchange(_lazyCustomAttributesBag, attributesBag, Nothing) 136If Interlocked.CompareExchange(_lazyDefaultValue, BindDefaultValue(inProgress, diagnostics), ConstantValue.Unset) Is ConstantValue.Unset Then
Symbols\Source\SourceDeclareMethodSymbol.vb (1)
68Dim old = Interlocked.CompareExchange(_lazyMetadataName, metadataName, Nothing)
Symbols\Source\SourceFile.vb (1)
100Interlocked.CompareExchange(_lazyQuickAttributeChecker, CreateQuickAttributeChecker(), Nothing)
Symbols\Source\SourceLambdaSymbol.vb (1)
60Dim oldValue As NamedTypeSymbol = Interlocked.CompareExchange(Me._lazyAnonymousDelegateSymbol, newValue, ErrorTypeSymbol.UnknownResultType)
Symbols\Source\SourceMemberContainerTypeSymbol.vb (1)
1602Interlocked.CompareExchange(_lazyTypeMembers, MakeTypeMembers(), Nothing)
Symbols\Source\SourceMemberFieldSymbol.vb (1)
67Interlocked.CompareExchange(Of ParameterSymbol)(_lazyMeParameter, New MeParameterSymbol(Me), Nothing)
Symbols\Source\SourceMemberMethodSymbol.vb (1)
124Dim old = Interlocked.CompareExchange(_lazyMetadataName, metadataName, Nothing)
Symbols\Source\SourceMethodSymbol.vb (5)
1303Interlocked.CompareExchange(_lazyMeParameter, New MeParameterSymbol(Me), Nothing) 1407Interlocked.CompareExchange(lazyCustomAttributesBag, attributesBag, Nothing) 1419Interlocked.CompareExchange(lazyCustomAttributesBag, attributesBag, Nothing) 2181Interlocked.CompareExchange(_lazyOverriddenMethods, overriddenMembers, Nothing) 2183Interlocked.CompareExchange(_lazyReturnType, retType, Nothing)
Symbols\Source\SourceModuleSymbol.vb (8)
187Interlocked.CompareExchange(_lazyGlobalNamespace, globalNS, Nothing) 262Interlocked.CompareExchange(_lazyQuickAttributeChecker, CreateQuickAttributeChecker(), Nothing) 353If Interlocked.CompareExchange(_lazyBoundImports, BindImports(cancellationToken), Nothing) Is Nothing Then 363Interlocked.CompareExchange(_lazyBoundImportsAdditionalDiagnostics, New StrongBox(Of ReadOnlyBindingDiagnostic(Of AssemblySymbol))(diagnosticBag.ToReadOnlyAndFree()), Nothing) 828Return Interlocked.CompareExchange(variable, value, comparand) Is comparand AndAlso comparand Is Nothing 834stored = Interlocked.CompareExchange(variable, value, comparand) Is comparand 861Interlocked.CompareExchange(variable, value, comparand) 866If Interlocked.CompareExchange(variable, value, comparand) <> comparand AndAlso
Symbols\Source\SourceNamedTypeSymbol.vb (8)
1577Dim prev = Interlocked.CompareExchange(m_baseCycleDiagnosticInfo, diag, Nothing) 1604Dim prev = Interlocked.CompareExchange(m_baseCycleDiagnosticInfo, diag, Nothing) 1767If Interlocked.CompareExchange(Me._lazyEnumUnderlyingType, underlyingType, Nothing) Is Nothing Then 1937Interlocked.CompareExchange(_lazyCoClassType, Nothing, DirectCast(ErrorTypeSymbol.UnknownResultType, TypeSymbol)) 1943Interlocked.CompareExchange(_lazyCoClassType, Nothing, 2197Interlocked.CompareExchange(_comClassData, New ComClassData(attrData), Nothing) 2228Interlocked.CompareExchange(Me._lazyCoClassType, 2575Interlocked.CompareExchange(Me._lazyWithEventsOverrides,
Symbols\Source\SourceNamespaceSymbol.vb (3)
94Interlocked.CompareExchange(_lazyEmbeddedKind, value, EmbeddedSymbolKind.Unset) 128If Interlocked.CompareExchange(_nameToMembersMap, map, Nothing) Is Nothing Then 189Interlocked.CompareExchange(
Symbols\Source\SourcePropertyAccessorSymbol.vb (2)
157Interlocked.CompareExchange(_lazyMetadataName, overriddenMethod.MetadataName, Nothing) 159Interlocked.CompareExchange(_lazyMetadataName, _name, Nothing)
Symbols\Source\SourcePropertySymbol.vb (4)
424Dim old = Interlocked.CompareExchange(_lazyMetadataName, metadataName, Nothing) 841Interlocked.CompareExchange(_lazyOverriddenProperties, overriddenMembers, Nothing) 843Interlocked.CompareExchange(_lazyType, retType, Nothing) 903Interlocked.CompareExchange(Of ParameterSymbol)(_lazyMeParameter, New MeParameterSymbol(Me), Nothing)
Symbols\SpecialMembers.vb (2)
63Interlocked.CompareExchange(_lazySpecialTypeMembers, specialTypeMembers, Nothing) 74Interlocked.CompareExchange(_lazySpecialTypeMembers(member), result, DirectCast(ErrorTypeSymbol.UnknownResultType, Symbol))
Symbols\SubstitutedEventSymbol.vb (2)
69Interlocked.CompareExchange(Me._lazyType, 216Interlocked.CompareExchange(Me._lazyOverriddenOrHiddenMembers,
Symbols\Symbol_Attributes.vb (2)
272Interlocked.CompareExchange(lazyCustomAttributesBag, New CustomAttributesBag(Of VisualBasicAttributeData)(), Nothing) 296Interlocked.CompareExchange(lazyCustomAttributesBag, CustomAttributesBag(Of VisualBasicAttributeData).WithEmptyData(), Nothing)
Symbols\SynthesizedSymbols\SynthesizedAccessor.vb (1)
34Interlocked.CompareExchange(_lazyMetadataName, GenerateMetadataName(), Nothing)
Symbols\SynthesizedSymbols\SynthesizedMethodBase.vb (1)
183Interlocked.CompareExchange(_lazyMeParameter, New MeParameterSymbol(Me), Nothing)
Symbols\TypeSymbol.vb (3)
205Interlocked.CompareExchange(_lazyInterfacesAndTheirBaseInterfaces, MakeInterfacesAndTheirBaseInterfaces(Me.InterfacesNoUseSiteDiagnostics), Nothing) 677Return If(Interlocked.CompareExchange(_lazyImplementationForInterfaceMemberMap, map, Nothing), map) 721Interlocked.CompareExchange(Me.m_lazyExplicitInterfaceImplementationMap, MakeExplicitInterfaceImplementationMap(), Nothing)
Symbols\UnboundGenericType.vb (3)
402Interlocked.CompareExchange(_lazyContainingSymbol, result, Nothing) 424Interlocked.CompareExchange(_lazyConstructedFrom, result, Nothing) 484Interlocked.CompareExchange(_lazyTypeSubstitution, result, Nothing)
Symbols\UsedAssemblies.vb (1)
196Interlocked.CompareExchange(_lazyUsedAssemblyReferences, New ConcurrentSet(Of AssemblySymbol)(), Nothing)
Symbols\WellKnownMembers.vb (5)
120Interlocked.CompareExchange(_lazyExtensionAttributeConstructor, 322Interlocked.CompareExchange(_lazyWellKnownTypeMembers, wellKnownTypeMembers, Nothing) 336Interlocked.CompareExchange(_lazyWellKnownTypeMembers(member), result, DirectCast(ErrorTypeSymbol.UnknownResultType, Symbol)) 372Interlocked.CompareExchange(_lazyWellKnownTypes, 409If (Interlocked.CompareExchange(_lazyWellKnownTypes(index), result, Nothing) IsNot Nothing) Then
Syntax\VisualBasicSyntaxNode.vb (1)
81Dim alternativeTree As SyntaxTree = Interlocked.CompareExchange(stack.Pop()._syntaxTree, tree, Nothing)
Syntax\VisualBasicSyntaxTree.LazySyntaxTree.vb (1)
78Interlocked.CompareExchange(_lazyRoot, root, Nothing)
Syntax\VisualBasicSyntaxTree.ParsedSyntaxTree.vb (1)
78Interlocked.CompareExchange(_lazyText, treeText, Nothing)
Syntax\VisualBasicSyntaxTree.vb (3)
417Interlocked.CompareExchange(_lineDirectiveMap, New VisualBasicLineDirectiveMap(Me), Nothing) 476Interlocked.CompareExchange(_lazyWarningStateMap, New VisualBasicWarningStateMap(Me), Nothing) 576Interlocked.CompareExchange(_lazySymbolsMap, ConditionalSymbolsMap.Create(Me.GetRoot(CancellationToken.None), Options), ConditionalSymbolsMap.Uninitialized)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.vb (1)
123Interlocked.CompareExchange(Me._lineContinuations(indentation), triviaInfo, Nothing)
Microsoft.CodeAnalysis.VisualBasic.Features (2)
Completion\VisualBasicCompletionService.vb (1)
70Interlocked.Exchange(_latestRules, newRules)
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.vb (1)
65Interlocked.CompareExchange(_diagnostics, ImmutableArray.CreateBuilder(Of Diagnostic)(), Nothing)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (2)
Formatting\Engine\Trivia\TriviaDataFactory.vb (1)
123Interlocked.CompareExchange(Me._lineContinuations(indentation), triviaInfo, Nothing)
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.ParsedSyntaxTree.vb (1)
44Interlocked.CompareExchange(_lazyText, GetRoot(cancellationToken).GetText(Encoding, _checksumAlgorithm), Nothing)
Microsoft.CodeAnalysis.Workspaces (66)
FindSymbols\FindReferences\FindReferenceCache.cs (1)
101Interlocked.CompareExchange(ref _aliasNameSet, set, null);
Log\CorrelationIdFactory.cs (1)
14=> Interlocked.Increment(ref s_globalId);
Log\CountLogAggregator.cs (2)
53Interlocked.Increment(ref _count); 60Interlocked.Add(ref _count, value);
Log\RoslynEventSource.LogBlock.cs (1)
104=> Interlocked.Increment(ref s_lastUniqueBlockId);
Remote\RemoteServiceCallbackDispatcher.cs (1)
39var callbackId = new RemoteServiceCallbackId(Interlocked.Increment(ref _callbackId));
SemanticModelReuse\SemanticModelWorkspaceServiceFactory.SemanticModelWorkspaceService.cs (1)
122Interlocked.CompareExchange(ref _semanticModelMap, updatedMap, originalMap);
Shared\TestHooks\AsynchronousOperationListener.cs (1)
133var oldSource = Interlocked.Exchange(ref _expeditedDelayCancellationTokenSource, new CancellationTokenSource());
Shared\Utilities\StreamingProgressTracker.cs (2)
21Interlocked.Add(ref _totalItems, count); 27Interlocked.Add(ref _completedItems, count);
src\Compilers\Core\Portable\Collections\TemporaryArray`1.cs (1)
153Interlocked.Exchange(ref _builder, null)?.Free();
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value; 21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue); 117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue); 152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
src\Compilers\Core\Portable\InternalUtilities\SemaphoreSlimExtensions.cs (1)
47var semaphoreToDispose = Interlocked.Exchange(ref _semaphore, null);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
672return Interlocked.Increment(ref StringTable.s_sharedRandom);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (2)
29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (2)
29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (2)
29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\RoslynImmutableInterlocked.cs (2)
620Interlocked.MemoryBarrier(); 633Interlocked.MemoryBarrier();
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\Logger.cs (2)
34return Interlocked.Exchange(ref s_currentLogger, logger); 154=> Interlocked.Increment(ref s_lastUniqueBlockId);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AnnotationTable.cs (1)
46var id = Interlocked.Increment(ref _globalId);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CancellableLazy`1.cs (2)
58Interlocked.Exchange<Func<CancellationToken, T>?>(ref _valueFactory, null); 61Interlocked.Exchange(ref _gate, null);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\RoslynParallel.NetFramework.cs (2)
459Interlocked.Increment(ref _completionRefCount); 478public bool SignalWorkerCompletedIterating() => Interlocked.Decrement(ref _completionRefCount) == 0;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Workspace\Mef\MefWorkspaceServices.cs (1)
75var allLanguageServices = Interlocked.Exchange(ref _languageServicesMap, _languageServicesMap.Clear());
Utilities\CancellationSeries.cs (2)
81var candidate = Interlocked.CompareExchange(ref _cts, nextSource, priorSource); 116var source = Interlocked.Exchange(ref _cts, null);
Workspace\Host\Mef\MefHostServices.cs (1)
84Interlocked.CompareExchange(ref s_defaultHost, host, null);
Workspace\Host\TemporaryStorage\LegacyTemporaryStorageService.cs (3)
62var existingValue = Interlocked.CompareExchange(ref _stream, newStream, null); 77var existingValue = Interlocked.CompareExchange(ref _stream, newStream, null); 103var existingValue = Interlocked.CompareExchange(ref _sourceText, text, null);
Workspace\ProjectSystem\ProjectSystemProject.cs (2)
536if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0) 544if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
Workspace\Solution\Document.cs (4)
97Interlocked.CompareExchange(ref _syntaxTreeResultTask, result, null); 189Interlocked.CompareExchange(ref _syntaxTreeResultTask, Task.FromResult(tree), null); 358var original = Interlocked.CompareExchange(ref disableNullableAnalysis ? ref _nullableDisabledModel : ref _model, new WeakReference<SemanticModel>(result), null); 590Interlocked.CompareExchange(ref _cachedOptions, newAsyncLazy, comparand: null);
Workspace\Solution\DocumentState_LinkedFileReuse.cs (5)
192Interlocked.Increment(ref s_tryReuseSyntaxTree); 202Interlocked.Increment(ref s_couldReuseBecauseOfEqualPPNames); 209Interlocked.Increment(ref s_couldReuseBecauseOfNoDirectives); 218Interlocked.Increment(ref s_couldReuseBecauseOfNoPPDirectives); 228Interlocked.Increment(ref s_couldNotReuse);
Workspace\Solution\ProjectState.cs (2)
160Interlocked.CompareExchange( 176Interlocked.CompareExchange(
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker.cs (3)
1018Interlocked.CompareExchange( 1057Interlocked.CompareExchange( 1095Interlocked.CompareExchange(
Workspace\Solution\SolutionCompilationState.WithFrozenSourceGeneratedDocumentsCompilationTracker.cs (2)
137Interlocked.CompareExchange(ref _compilationWithReplacements, newCompilation, null); 154Interlocked.CompareExchange(
Workspace\Solution\VersionSource\RecoverableTextAndVersion.cs (3)
94Interlocked.CompareExchange( 108Interlocked.Exchange( 198Interlocked.CompareExchange(ref _storageHandle, handle, null);
Workspace\Solution\VersionStamp.cs (1)
187var globalVersion = Interlocked.Increment(ref VersionStamp.s_globalVersion);
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
MSBuild\BuildHostProcessManager.cs (1)
424if (Interlocked.CompareExchange(ref _disposed, value: 1, comparand: 0) != 0)
Rpc\RpcClient.cs (1)
144requestId = Interlocked.Increment(ref _nextRequestId);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (23)
Rpc\RpcServer.cs (1)
49var nextIndex = Interlocked.Increment(ref _nextRpcTargetIndex);
src\Compilers\Core\Portable\Collections\TemporaryArray`1.cs (1)
153Interlocked.Exchange(ref _builder, null)?.Free();
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value; 21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue); 117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/> 141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue); 152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
src\Compilers\Core\Portable\InternalUtilities\SemaphoreSlimExtensions.cs (1)
47var semaphoreToDispose = Interlocked.Exchange(ref _semaphore, null);
src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (1)
58switch (Interlocked.CompareExchange(ref _initialized, value: 1, comparand: 0))
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
672return Interlocked.Increment(ref StringTable.s_sharedRandom);
src\Compilers\Core\Portable\InternalUtilities\ThreadSafeFlagOperations.cs (2)
23while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState); 39while (Interlocked.CompareExchange(ref flags, newState, oldState) != oldState);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (2)
29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (2)
29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (2)
29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\RoslynImmutableInterlocked.cs (2)
620Interlocked.MemoryBarrier(); 633Interlocked.MemoryBarrier();
src\Dependencies\PooledObjects\ObjectPool`1.cs (2)
150if (inst == null || inst != Interlocked.CompareExchange(ref _firstItem, null, inst)) 179if (inst == Interlocked.CompareExchange(ref items[i].Value, null, inst))
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
src\Workspaces\Core\MSBuild.BuildHost\Rpc\RpcServer.cs (1)
49var nextIndex = Interlocked.Increment(ref _nextRpcTargetIndex);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (4)
MEF\ExportProviderCache.cs (3)
142var expectedCatalog = Interlocked.CompareExchange(ref _scope.ExpectedCatalog, _catalog, null) ?? _catalog; 178expected = Interlocked.CompareExchange(ref _scope.ExpectedProviderForCatalog, expected, null) ?? expected; 179Interlocked.CompareExchange(ref _scope.CurrentExportProvider, expected, null);
MEF\UseExportProviderAttribute.cs (1)
195Interlocked.CompareExchange(
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
UtilityTest\AsyncLazyTests.cs (1)
232Interlocked.Increment(ref computations);
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.AsyncState (1)
AsyncState.cs (1)
49return new AsyncStateToken(Interlocked.Increment(ref _contextCount) - 1);
Microsoft.Extensions.Caching.Hybrid (7)
Internal\DefaultHybridCache.CacheItem.cs (2)
47int newCount = Interlocked.Decrement(ref _refCount); 72var updated = Interlocked.CompareExchange(ref _refCount, oldValue + 1, oldValue);
Internal\DefaultHybridCache.Debug.cs (3)
35=> flush ? Interlocked.Exchange(ref _outstandingBufferCount, 0) : Volatile.Read(ref _outstandingBufferCount); 40_ = Interlocked.Decrement(ref _outstandingBufferCount); 46_ = Interlocked.Increment(ref _outstandingBufferCount);
Internal\RecyclableArrayBufferWriter.cs (2)
52var obj = Interlocked.Exchange(ref _spare, null) ?? new(); 70if (Interlocked.CompareExchange(ref _spare, this, null) != null)
Microsoft.Extensions.Caching.Hybrid.Tests (21)
L2Tests.cs (12)
166Interlocked.Increment(ref ProtectedOpCount); 173Interlocked.Increment(ref ProtectedOpCount); 180Interlocked.Increment(ref ProtectedOpCount); 194Interlocked.Increment(ref ProtectedOpCount); 218Interlocked.Increment(ref ProtectedOpCount); 225Interlocked.Increment(ref ProtectedOpCount); 232Interlocked.Increment(ref ProtectedOpCount); 239Interlocked.Increment(ref ProtectedOpCount); 246Interlocked.Increment(ref ProtectedOpCount); 253Interlocked.Increment(ref ProtectedOpCount); 260Interlocked.Increment(ref ProtectedOpCount); 267Interlocked.Increment(ref ProtectedOpCount);
RedisTests.cs (1)
77Interlocked.Increment(ref count);
StampedeTests.cs (8)
83using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 89Interlocked.Increment(ref executeCount); 119using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 125Interlocked.Increment(ref executeCount); 172using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 180Interlocked.Increment(ref executeCount); 250using var reg = ct.Register(() => Interlocked.Increment(ref cancelCount)); 258Interlocked.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)
188Interlocked.Add(ref coherentState._cacheSize, -entry.Size + (priorEntry?.Size).GetValueOrDefault()); 242Interlocked.Increment(ref GetStats().Hits); 263Interlocked.Increment(ref GetStats().Misses); 283Interlocked.Add(ref coherentState._cacheSize, -entry.Size); 300CoherentState oldState = Interlocked.Exchange(ref _coherentState, new CoherentState()); 365hits += Interlocked.Read(ref stats.Hits); 366misses += Interlocked.Read(ref stats.Misses); 406_accumulatedStats!.Hits += Interlocked.Read(ref current.Hits); 407_accumulatedStats.Misses += Interlocked.Read(ref current.Misses); 468long original = Interlocked.CompareExchange(ref coherentState._cacheSize, newSize, sizeRead); 488if (Interlocked.CompareExchange(ref lockFlag, 1, 0) == 0) 694Interlocked.Add(ref _cacheSize, -entry.Size);
Microsoft.Extensions.Caching.StackExchangeRedis (2)
RedisCache.cs (2)
617ReleaseConnection(Interlocked.Exchange(ref _cache, null)); 669var tmp = Interlocked.CompareExchange(ref _cache, null, cache);
Microsoft.Extensions.Compliance.Testing (2)
FakeRedactor.cs (1)
83var order = Interlocked.Increment(ref _redactedSoFar);
FakeRedactorProvider.cs (1)
37var order = Interlocked.Increment(ref _redactorsRequestedSoFar);
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.Diagnostics.Testing (1)
Metrics\MetricCollector.cs (1)
278if (Interlocked.CompareExchange(ref _instrument, instrument, null) is null)
Microsoft.Extensions.Http.Diagnostics (1)
Latency\Internal\HttpRequestLatencyListener.cs (1)
43if (Interlocked.CompareExchange(ref _enabled, 1, 0) == 0)
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Latency\Internal\HttpMockProvider.cs (1)
49Interlocked.Increment(ref OnEventInvoked);
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)
171int id = Interlocked.Increment(ref _activityIds);
EventSourceLoggerProvider.cs (1)
32_factoryID = Interlocked.Increment(ref _globalFactoryID);
LoggingEventSource.cs (1)
390CancellationTokenSource? tcs = Interlocked.Exchange(ref _cancellationTokenSource, null);
Microsoft.Extensions.ML (3)
ModelLoaders\FileModelLoader.cs (1)
72var previousToken = Interlocked.Exchange(ref _reloadToken, new ModelReloadToken());
ModelLoaders\UriModelLoader.cs (1)
85var previousToken = Interlocked.Exchange(ref _reloadToken, new ModelReloadToken());
PoolLoader.cs (1)
45Interlocked.Exchange(ref _pool, new DefaultObjectPool<PredictionEngine<TData, TPrediction>>(predictionEnginePolicy));
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.Extensions.ServiceDiscovery (14)
Http\HttpServiceEndpointResolver.cs (6)
191var status = Interlocked.And(ref _status, ~RecentUseFlag); 201var status = Interlocked.Increment(ref _status); 218Interlocked.Or(ref _status, RecentUseFlag); 222var status = Interlocked.Decrement(ref _status); 234Interlocked.CompareExchange(ref _onDisposed, new(TaskCreationOptions.RunContinuationsAsynchronously), null); 237var status = Interlocked.Or(ref _status, DisposingFlag);
LoadBalancing\RoundRobinServiceEndpointSelector.cs (1)
28return collection[(int)(Interlocked.Increment(ref _next) % collection.Count)];
ServiceEndpointResolver.cs (6)
184var status = Interlocked.And(ref _status, ~RecentUseFlag); 194var status = Interlocked.Increment(ref _status); 210Interlocked.Or(ref _status, RecentUseFlag); 214var status = Interlocked.Decrement(ref _status); 226Interlocked.CompareExchange(ref _onDisposed, new(TaskCreationOptions.RunContinuationsAsynchronously), null); 229var status = Interlocked.Or(ref _status, DisposingFlag);
ServiceEndpointWatcher.cs (1)
194Interlocked.Exchange(ref _cachedEndpoints, null);
Microsoft.Extensions.Telemetry (4)
Latency\Internal\CheckpointTracker.cs (2)
66if (token.Position > -1 && Interlocked.CompareExchange(ref _checkpointAdded[token.Position], 1, 0) == 0) 68var p = Interlocked.Increment(ref _numCheckpoints);
Latency\Internal\LatencyConsoleExporter.cs (1)
48var cnt = Interlocked.Increment(ref _sampleCount);
Latency\Internal\MeasureTracker.cs (1)
70_ = Interlocked.Add(ref _measureValues[pos], value);
Microsoft.Extensions.TimeProvider.Testing (1)
FakeTimeProvider.cs (1)
236if (Interlocked.CompareExchange(ref _wakeWaitersGate, 1, 0) == 1)
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.Maui (4)
Animations\Animation.cs (2)
155 if (0 == Interlocked.Exchange(ref _usingResource, 1)) 165 Interlocked.Exchange(ref _usingResource, 0);
Handlers\HybridWebView\HybridWebViewHandler.cs (1)
429 return Interlocked.Increment(ref _asyncInvokeTaskId);
Platform\ActionDisposable.cs (1)
18 Interlocked.Exchange(ref _action, null)?.Invoke();
Microsoft.Maui.Controls (11)
DataTemplate.cs (3)
20 _id = Interlocked.Increment(ref idCounter); 29 _id = Interlocked.Increment(ref idCounter); 36 _id = Interlocked.Increment(ref idCounter);
ImageSource.cs (2)
58 TaskCompletionSource<bool> original = Interlocked.CompareExchange(ref _completionSource, new TaskCompletionSource<bool>(), null); 129 TaskCompletionSource<bool> tcs = Interlocked.Exchange(ref _completionSource, null);
NavigationPage\NavigationPage.cs (2)
636 Interlocked.Increment(ref _waitingCount); 674 if (Interlocked.Decrement(ref _waitingCount) == 0)
Performance.cs (1)
41 reference = Interlocked.Increment(ref Reference).ToString();
Shell\ShellNavigatingDeferral.cs (1)
21 var taskToComplete = Interlocked.Exchange(ref _completed, null);
Shell\ShellNavigatingEventArgs.cs (2)
64 var currentCount = Interlocked.Increment(ref _deferralCount); 75 if (Interlocked.Decrement(ref _deferralCount) == 0)
Microsoft.Maui.Controls.Compatibility (2)
iOS\Renderers\WkWebViewRenderer.cs (1)
273 if (Interlocked.Decrement(ref _sharedPoolCount) == 0 && Forms.IsiOS12OrNewer)
iOS\VisualElementTracker.cs (1)
216 var updateTarget = Interlocked.Increment(ref _updateCount);
Microsoft.Maui.Controls.Foldable (2)
DualScreenInfo.cs (2)
103 ProcessHingeAngleSubscriberCount(Interlocked.Increment(ref subscriberCount)); 108 ProcessHingeAngleSubscriberCount(Interlocked.Decrement(ref subscriberCount));
Microsoft.Maui.Graphics.Skia (1)
SkiaImage.cs (1)
143 var previousValue = Interlocked.Exchange(ref _image, null);
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (1)
src\Graphics\src\Graphics\Platforms\Windows\PlatformImage.cs (1)
46 var bitmap = Interlocked.Exchange(ref _bitmap, null);
Microsoft.ML.AutoML.Interactive (1)
ActionThrottler.cs (1)
36if (Interlocked.CompareExchange(ref _updatePending, 1, 0) == 0) // _updatePending is int initialized with 0
Microsoft.ML.CodeAnalyzer.Tests (1)
Helpers\TestUtils.cs (1)
22Interlocked.CompareExchange(ref source, loadedSource, null);
Microsoft.ML.Core (11)
Data\AnnotationUtils.cs (1)
170Interlocked.CompareExchange(ref _scoreColumnSetIdType, new KeyDataViewType(typeof(uint), int.MaxValue), null) ??
Data\ProgressReporter.cs (1)
147var newId = Interlocked.Increment(ref _maxSubId);
Environment\ConsoleEnvironment.cs (1)
448_oldConsoleWriter = Interlocked.Exchange(ref _root._consoleWriter, _newConsoleWriter);
Utilities\CharUtils.cs (2)
22Interlocked.CompareExchange(ref _lowerInvariantChars, lower, null); 31Interlocked.CompareExchange(ref _upperInvariantChars, upper, null);
Utilities\Contracts.cs (1)
239return Interlocked.Exchange(ref _handler, handler);
Utilities\ObjectPool.cs (1)
54Interlocked.Increment(ref _numCreated);
Utilities\PathUtils.cs (1)
30Interlocked.CompareExchange(ref _dllDir, directory, null);
Utilities\ResourceManagerUtils.cs (1)
31Interlocked.CompareExchange(ref _instance, new ResourceManagerUtils(), null) ??
Utilities\Stream.cs (1)
945Interlocked.CompareExchange(ref _utf8NoBom, new UTF8Encoding(false), null);
Utilities\Utils.cs (1)
481snapshotOfTargetDuring = Interlocked.CompareExchange(ref target, targetPlusV, snapshotOfTargetBefore);
Microsoft.ML.CpuMath (1)
src\Microsoft.ML.Core\Utilities\Contracts.cs (1)
239return Interlocked.Exchange(ref _handler, handler);
Microsoft.ML.Data (33)
Data\Combiner.cs (5)
28Interlocked.CompareExchange(ref _instance, new TextCombiner(), null) ?? 54Interlocked.CompareExchange(ref _instance, new FloatAdder(), null) ?? 76Interlocked.CompareExchange(ref _instance, new R4Adder(), null); 98Interlocked.CompareExchange(ref _instance, new R8Adder(), null) ?? 121Interlocked.CompareExchange(ref _instance, new U4Adder(), null) ??
Data\Conversion.cs (1)
64Interlocked.CompareExchange(ref _defaultInstance, new Conversions(), null) ??
Data\DataViewUtils.cs (2)
610int remaining = Interlocked.Decrement(ref outputsRunning); 666Interlocked.CompareExchange(ref _cachePools[poolIdx], new MadeObjectPool<T[]>(() => null), null);
DataLoadSave\Binary\BinaryLoader.cs (1)
1394long seq = Interlocked.Increment(ref decompressSequence);
DataLoadSave\Binary\MemoryStreamPool.cs (1)
65Interlocked.CompareExchange(ref _pools[index], new MemoryStreamPool(), null);
DataLoadSave\Text\TextLoaderCursor.cs (2)
445int n = Interlocked.Decrement(ref _cref); 966if (Interlocked.Decrement(ref _threadsRunning) <= 0)
DataLoadSave\Text\TextLoaderParser.cs (8)
40Interlocked.CompareExchange(ref _defaultInstance, new ValueCreatorCache(), null) ?? 164int n = Interlocked.Decrement(ref _cref); 180Interlocked.Increment(ref _rowCount); 185long n = Interlocked.Increment(ref _badCount); 196long n = Interlocked.Increment(ref _badCount); 207long n = Interlocked.Increment(ref _fmtCount); 1493Interlocked.CompareExchange(ref _csrc, csrc, 0); 1498if (Interlocked.Increment(ref _mismatchCount) == 1)
DataLoadSave\Transpose\TransposeLoader.cs (1)
190var view = Interlocked.CompareExchange(ref _view, loader, null);
DataView\CacheDataView.cs (3)
423long rc = Interlocked.CompareExchange(ref _rowCount, rowCount, -1); 930return Interlocked.Increment(ref _c); 1298Interlocked.CompareExchange(ref _pipeConstructorTypes,
Deprecated\Instances\HeaderSchema.cs (1)
274Interlocked.CompareExchange(ref _lock, new object(), null);
Evaluators\EvaluatorUtils.cs (1)
51Interlocked.CompareExchange(ref _knownEvaluatorFactories, tmp, null);
Evaluators\RankingEvaluator.cs (1)
983Interlocked.CompareExchange(ref _discountMapFixed, discountMap, null);
Prediction\Calibrator.cs (1)
1384_random = new System.Random(System.Threading.Interlocked.Increment(ref _randSeed) - 1);
Scorers\MulticlassClassificationScorer.cs (1)
273Interlocked.CompareExchange(ref _bindable,
Transforms\LabelConvertTransform.cs (1)
191Interlocked.CompareExchange(ref _slotType, new VectorDataViewType(NumberDataViewType.Single, srcSlotType.Dimensions), null);
Transforms\RowShufflingTransformer.cs (1)
387Interlocked.CompareExchange(ref _pipeConstructorTypes, new Type[] { typeof(int), typeof(Delegate) }, null);
Transforms\ValueToKeyMappingTransformer.cs (2)
189Interlocked.CompareExchange(ref _codecFactoryPool, new MemoryStreamPool(), null); 190Interlocked.CompareExchange(ref _codecFactory, new CodecFactory(Host, _codecFactoryPool), null);
Microsoft.ML.DataView (16)
DataViewType.cs (16)
100Interlocked.CompareExchange(ref _instance, new TextDataViewType(), null) ?? 141Interlocked.CompareExchange(ref _instSByte, new NumberDataViewType(typeof(sbyte)), null) ?? 155Interlocked.CompareExchange(ref _instByte, new NumberDataViewType(typeof(byte)), null) ?? 169Interlocked.CompareExchange(ref _instInt16, new NumberDataViewType(typeof(short)), null) ?? 183Interlocked.CompareExchange(ref _instUInt16, new NumberDataViewType(typeof(ushort)), null) ?? 197Interlocked.CompareExchange(ref _instInt32, new NumberDataViewType(typeof(int)), null) ?? 211Interlocked.CompareExchange(ref _instUInt32, new NumberDataViewType(typeof(uint)), null) ?? 225Interlocked.CompareExchange(ref _instInt64, new NumberDataViewType(typeof(long)), null) ?? 239Interlocked.CompareExchange(ref _instUInt64, new NumberDataViewType(typeof(ulong)), null) ?? 253Interlocked.CompareExchange(ref _instSingle, new NumberDataViewType(typeof(float)), null) ?? 267Interlocked.CompareExchange(ref _instDouble, new NumberDataViewType(typeof(double)), null) ?? 298Interlocked.CompareExchange(ref _instance, new RowIdDataViewType(), null) ?? 337Interlocked.CompareExchange(ref _instance, new BooleanDataViewType(), null) ?? 376Interlocked.CompareExchange(ref _instance, new DateTimeDataViewType(), null) ?? 412Interlocked.CompareExchange(ref _instance, new DateTimeOffsetDataViewType(), null) ?? 448Interlocked.CompareExchange(ref _instance, new TimeSpanDataViewType(), null) ??
Microsoft.ML.FastTree (9)
BinFile\BinFinder.cs (1)
30Interlocked.CompareExchange(ref _trivialBinUpperBounds, new double[] { double.PositiveInfinity }, null) ??
GamTrainer.cs (1)
517Interlocked.CompareExchange(ref meanEffects[featureIndex], newTotalEffect, totalEffect));
SumupPerformanceCommand.cs (1)
306Interlocked.Increment(ref completed);
Training\Test.cs (2)
636Interlocked.Add(ref totalNpos, localNpos); 637Interlocked.Add(ref totalNneg, localNneg);
Utils\Timer.cs (4)
203Interlocked.CompareExchange(ref _state, new TimerState(), null); 219Interlocked.Add(ref _state.CountTotals[(int)e], counts); 240Interlocked.Add(ref _state.TickTotals[(int)_event], _state.Watch.ElapsedTicks - _ticksBegin); 241Interlocked.Increment(ref _state.NumCalls[(int)_event]);
Microsoft.ML.StandardTrainers (2)
Standard\SdcaBinary.cs (1)
849success = Interlocked.CompareExchange(ref value, dual + dualUpdate, dual) == dual;
Standard\SdcaMulticlass.cs (1)
266success = Interlocked.CompareExchange(ref value, dual + dualUpdate, dual) == dual);
Microsoft.ML.Tests (3)
CachingTests.cs (1)
30get { Interlocked.Increment(ref AccessCount); return _features; }
ExpressionLanguageTests\ExpressionLanguageTests.cs (2)
436Interlocked.CompareExchange(ref _instance, new TestFuncs1(), null); 620Interlocked.CompareExchange(ref _instance, new TestFuncs2(), null);
Microsoft.ML.TimeSeries (3)
SequentialAnomalyDetectionTransformBase.cs (1)
408if (Interlocked.Increment(ref _parent.StateRefCount) > 1)
SequentialForecastingTransformBase.cs (1)
257if (Interlocked.Increment(ref _parent.StateRefCount) > 1)
SrCnnTransformBase.cs (1)
251if (Interlocked.Increment(ref _parent.StateRefCount) > 1)
Microsoft.ML.Tokenizers (3)
Model\CodeGenTokenizer.cs (1)
267Interlocked.CompareExchange(ref _vocabOriginal, vocab, null);
Model\EnglishRobertaTokenizer.cs (1)
245Interlocked.CompareExchange(ref _vocabOriginal, vocab, null);
Model\SentencePieceTokenizer.cs (1)
182Interlocked.CompareExchange(ref _publicVocab, new ReadOnlyDictionary<string, int>(vocab), null);
Microsoft.ML.Transforms (7)
Expression\BuiltinFunctions.cs (1)
121Interlocked.CompareExchange(ref _instance, new BuiltinFunctions(), null);
Text\StopWordsRemovingTransformer.cs (3)
156Interlocked.CompareExchange(ref _stopWords, stopWords, null); 173Interlocked.CompareExchange(ref _langsDictionary, langsDictionary, null); 337Interlocked.CompareExchange(ref StopWords[(int)lang], stopWordsList, null);
Text\TextNormalizing.cs (1)
318Interlocked.CompareExchange(ref _combinedDiacriticsMap, combinedDiacriticsMap, null);
Text\TokenizingByCharacters.cs (2)
316Interlocked.CompareExchange(ref _keyValuesBoundaries, boundaries, null); 317Interlocked.CompareExchange(ref _keyValuesStr, bldr.ToString(), null);
Microsoft.NET.StringTools (1)
WeakStringCache.Concurrent.cs (1)
73if (Interlocked.CompareExchange(ref _scavengeThreshold, int.MaxValue, scavengeThreshold) == scavengeThreshold)
Microsoft.VisualBasic.Forms (1)
Microsoft\VisualBasic\MyServices\Internal\ContextValue.vb (1)
53Interlocked.CompareExchange(s_threadLocal, New ThreadLocal(Of IDictionary)(Function() New Dictionary(Of String, T)), Nothing)
Microsoft.VisualBasic.Tests (3)
Microsoft\VisualBasic\ApplicationServices\SingleInstanceTests.cs (3)
27Interlocked.CompareExchange(ref _received, null, received); 110Interlocked.Increment(ref created); 118Interlocked.Increment(ref completed);
Microsoft.VisualStudio.IntegrationTest.Setup (3)
AsyncCompletionTracker.cs (2)
71Interlocked.Exchange(ref token, null)?.Dispose(); 72if (Interlocked.Exchange(ref cancellationSource, null) is { } source)
TestTraceListener.cs (1)
130var failures = Interlocked.Exchange(ref _failures, []);
Microsoft.VisualStudio.LanguageServices (8)
Diagnostics\VisualStudioDiagnosticAnalyzerService.cs (1)
405Interlocked.Increment(ref _analyzedProjectCount);
EditAndContinue\EditAndContinueFeedbackDiagnosticFileProvider.cs (2)
112if (Interlocked.CompareExchange(ref _isLogCollectionInProgress, 1, 0) == 0) 120if (Interlocked.Exchange(ref _isLogCollectionInProgress, 0) == 1)
EditorConfigSettings\Common\SettingsSnapshotFactoryBase.cs (1)
35internal void NotifyOfUpdate() => Interlocked.Increment(ref _currentVersionNumber);
LanguageClient\VisualStudioLogHubLoggerFactory.cs (1)
42var logName = $"Roslyn.{serverTypeName}.{Interlocked.Increment(ref s_logHubSessionId)}";
ProjectSystem\MetadataReferences\VisualStudioMetadataReferenceManagerFactory.cs (1)
29Interlocked.CompareExchange(ref _singleton, new VisualStudioMetadataReferenceManager(serviceProvider, temporaryStorage), null);
Watson\FaultReporter.cs (1)
148if (Interlocked.Increment(ref s_dumpsSubmitted) <= 3)
Workspace\VisualStudioSourceGeneratorTelemetryCollectorWorkspaceServiceFactory.cs (1)
72if (Interlocked.CompareExchange(ref _subscribedToSolutionEvents, 1, 0) == 0)
Microsoft.VisualStudio.LanguageServices.CSharp (5)
SemanticSearch\SemanticSearchToolWindow.cs (1)
66Interlocked.CompareExchange(ref _lazyContent, new WpfControlWrapper(element), null);
SemanticSearch\SemanticSearchToolWindowImpl.cs (4)
324var pendingExecutionCancellationSource = Interlocked.Exchange(ref _pendingExecutionCancellationSource, null); 339Interlocked.Exchange(ref _pendingExecutionCancellationSource, cancellationSource)?.Cancel(); 402Interlocked.CompareExchange(ref _pendingExecutionCancellationSource, value: null, cancellationSource); 405var source = Interlocked.Exchange(ref cancellationSource, null);
Microsoft.VisualStudio.LanguageServices.DevKit (1)
Logging\VSCodeTelemetryLogger.cs (1)
114if (Interlocked.Increment(ref _dumpsSubmitted) <= 3)
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)
39if (Interlocked.Increment(ref _mutex) == 1) 43Interlocked.Decrement(ref _mutex); 168if (Interlocked.Increment(ref _mutex) == 1) 178Interlocked.Decrement(ref _mutex); 196if (Interlocked.Increment(ref _mutex) == 1) 209Interlocked.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)
2025uint renderID = (uint)Interlocked.Increment(ref _contextRenderID);
System\Windows\Media\MediaSystem.cs (1)
152if (System.Threading.Interlocked.CompareExchange(ref s_DisableDirtyRectangles, disableDirtyRectangles, oldValue) == oldValue)
System\Windows\Media\SafeMILHandleMemoryPressure.cs (2)
30Interlocked.Increment(ref _refCount); 35if (Interlocked.Decrement(ref _refCount) == 0)
System\Windows\Media\textformatting\TextFormatterContext.cs (1)
461System.Threading.Interlocked.CompareExchange<Dictionary<char,bool>>(ref _specialCharacters, dict, null);
PresentationFramework (22)
MS\Internal\Data\CollectionViewProxy.cs (2)
171IndexedEnumerable indexer = (IndexedEnumerable)Interlocked.Exchange(ref _indexer, null); 1059Interlocked.CompareExchange(ref _indexer, newIndexer, null);
MS\Internal\Data\DataBindEngine.cs (3)
431if (Interlocked.Increment(ref _cleanupRequests) == 1) 595Interlocked.Exchange(ref _cleanupRequests, 0); 619HybridDictionary asyncDispatchers = (HybridDictionary)Interlocked.Exchange(ref _asyncDispatchers, null);
MS\Internal\PtsHost\FlowDocumentPage.cs (1)
801if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PageBreakRecord.cs (1)
134if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsCache.cs (2)
166if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0)) 293if (0 == Interlocked.CompareExchange(ref _disposed, 1, 0))
MS\Internal\PtsHost\PtsContext.cs (1)
75if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\PtsHost\PtsPage.cs (1)
708if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
MS\Internal\Utility\MonitorWrapper.cs (2)
23Interlocked.Increment(ref _enterCount); 29int count = Interlocked.Decrement(ref _enterCount);
MS\Win32\UxThemeWrapper.cs (1)
216ThemeState currentState = System.Threading.Interlocked.CompareExchange(ref _themeState, newState, themeState);
System\Windows\Data\BindingOperations.cs (2)
564Interlocked.CompareExchange<ExceptionLogger>(ref _exceptionLogger, newLogger, null); 591Interlocked.CompareExchange<ExceptionLogger>(ref _exceptionLogger, null, this);
System\Windows\Data\CollectionView.cs (2)
1437IndexedEnumerable wrapper = (IndexedEnumerable) Interlocked.Exchange(ref _enumerableWrapper, null); 1753Interlocked.CompareExchange(ref _enumerableWrapper, newWrapper, null);
System\Windows\Documents\WpfPayload.cs (1)
316int newWpfPayoutCount = Interlocked.Increment(ref _wpfPayloadCount);
System\Windows\FrameworkElementFactory.cs (1)
1149Interlocked.Increment(ref AutoGenChildNamePostfix);
System\Windows\StyleHelper.cs (1)
5338Interlocked.Increment(ref lastChildIndex);
System\Windows\SystemResources.cs (1)
838string currentName = System.Threading.Interlocked.CompareExchange(ref _themedResourceName, themedResourceName, null);
Roslyn.VisualStudio.DiagnosticsWindow (2)
PerfMargin\ActivityLevel.cs (2)
53var current = Interlocked.Increment(ref _isActive); 64var current = Interlocked.Decrement(ref _isActive);
ScenarioTests.Common.Tests (2)
ScenarioTestTypes.cs (2)
216Interlocked.Increment(ref _operationCount); 222Interlocked.Decrement(ref _operationCount) == 0)
Shared.Tests (1)
Pools\PoolTests.cs (1)
25SequenceNum = Interlocked.Increment(ref _fooSequenceNum);
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)
202if (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, Operation.Add); 752Interlocked.Exchange(ref _currentOp, 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); 96T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue); 138T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 185T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 205return new ImmutableArray<T>(Interlocked.Exchange(ref Unsafe.AsRef(in location.array), value.array)); 219return new ImmutableArray<T>(Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), value.array, comparand.array)); 323ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 371ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 418ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 452ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 487ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 518ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 552ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 575ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 607ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection); 630ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
System\Collections\Immutable\ImmutableList_1.Builder.cs (1)
1168System.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)
1287int ci = System.Threading.Interlocked.Increment(ref s_collisionIndex) - 1; 2380Interlocked.Increment(ref s_metadataVersion); 2446Interlocked.Increment(ref s_metadataVersion);
System.Composition.Hosting (1)
System\Composition\Hosting\Core\LifetimeContext.cs (1)
51return Interlocked.Increment(ref s_nextSharingId);
System.Configuration.ConfigurationManager (2)
System\Configuration\BaseConfigurationRecord.cs (1)
2825Interlocked.CompareExchange(ref s_appConfigPath, appConfigPath, null);
System\Configuration\SafeBitVector32.cs (1)
34int result = Interlocked.CompareExchange(ref _data, newData, oldData);
System.Console (2)
System\ConsolePal.Unix.cs (2)
92Interlocked.CompareExchange(ref s_stdInReader, reader, null); 1090bool 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); 1260view = 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.Data.Odbc (16)
Common\System\Data\ProviderBase\DbConnectionInternal.cs (1)
23int activateCount = Interlocked.Increment(ref _activateCount);
Common\System\Data\ProviderBase\DbConnectionPool.cs (9)
595started = Interlocked.CompareExchange(ref _pendingOpensWaiting, 1, 0) == 0; 658Interlocked.Exchange(ref _pendingOpensWaiting, 0); 721Interlocked.Increment(ref _waitCount); 745Interlocked.Decrement(ref _waitCount); 751Interlocked.Decrement(ref _waitCount); 764Interlocked.Decrement(ref _waitCount); 774Interlocked.Decrement(ref _waitCount); 800Interlocked.Decrement(ref _waitCount); 831Interlocked.Decrement(ref _waitCount);
src\libraries\Common\src\System\Data\ProviderBase\DbConnectionInternal.cs (1)
227Interlocked.Decrement(ref _activateCount);
System\Data\Odbc\OdbcCommand.cs (1)
24internal readonly int ObjectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\Odbc\OdbcConnectionHelper.cs (2)
143Interlocked.CompareExchange(ref _innerConnection, DbConnectionClosedPreviouslyOpened.SingletonInstance, innerConnection); 251bool result = (from == Interlocked.CompareExchange<DbConnectionInternal>(ref _innerConnection, to, from));
System\Data\Odbc\OdbcDataReader.cs (1)
48internal readonly int ObjectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount);
System\Data\Odbc\OdbcEnvironment.cs (1)
33object? globalEnvironmentHandle = Interlocked.Exchange(ref s_globalEnvironmentHandle, null);
System.Diagnostics.DiagnosticSource (38)
System\Diagnostics\Activity.cs (15)
251Interlocked.CompareExchange(ref _id, id, null); 283Interlocked.CompareExchange(ref _parentId, parentId, null); 287Interlocked.CompareExchange(ref _parentId, Parent.Id, null); 322Interlocked.CompareExchange(ref _rootId, rootId, null); 490if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp), null) != null) 514if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp, set: true), null) != null) 529if (_events != null || Interlocked.CompareExchange(ref _events, new DiagLinkedList<ActivityEvent>(e), null) != null) 617if (_links != null || Interlocked.CompareExchange(ref _links, new DiagLinkedList<ActivityLink>(link), null) != null) 638if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp), null) != null) 662if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp, set: true), null) != null) 918Interlocked.CompareExchange(ref _spanId, spanId, null); 998Interlocked.CompareExchange(ref _parentSpanId, parentSpanId, null); 1139Interlocked.CompareExchange(ref _customProperties, new Dictionary<string, object>(), null); 1329ret = AppendSuffix(Parent.Id, Interlocked.Increment(ref Parent._currentChildId).ToString(), '.'); 1346ret = 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)
361Interlocked.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\DsesFilterAndTransform.cs (2)
432Interlocked.CompareExchange(ref _firstImplicitTransformsEntry, 443Interlocked.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\InstrumentState.cs (1)
30ID = Interlocked.Increment(ref s_idCounter);
System\Diagnostics\Metrics\MetricsEventSource.cs (3)
86Interlocked.CompareExchange(ref _handler, new CommandHandler(this), null); 496&& ((!_disabledRefCount && Interlocked.Decrement(ref _sharedSessionRefCount) == 0) 539Interlocked.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)
87long bootTimeTicks = Interlocked.Read(ref s_bootTimeTicks); 91long 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)
26Interlocked.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)
1107if (Interlocked.Exchange(ref _activeAsyncOperation, true))
System.IO.Compression.Brotli (1)
System\IO\Compression\BrotliStream.cs (1)
185if (Interlocked.Exchange(ref _activeAsyncOperation, true))
System.IO.MemoryMappedFiles (1)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.MemfdCreate.cs (1)
27Interlocked.CompareExchange(ref s_memfdSupported, (sbyte)(MemfdSupportedImpl() == 1 ? 1 : -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, true); 561Interlocked.Exchange(ref _consumerIsWaiting, true); 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 (48)
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\Headers\HttpHeaders.cs (1)
755object previousValue = Interlocked.CompareExchange(ref storeValueRef, info, value);
System\Net\Http\HttpClient.cs (1)
681CancellationTokenSource currentCts = Interlocked.Exchange(ref _pendingRequestsCts, new CancellationTokenSource());
System\Net\Http\HttpClientHandler.cs (1)
375Interlocked.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)
40Interlocked.Increment(ref _startedRequests); 76Interlocked.Increment(ref _stoppedRequests); 83Interlocked.Increment(ref _failedRequests); 209Interlocked.Increment(ref _openedHttp11Connections); 216long count = Interlocked.Decrement(ref _openedHttp11Connections); 224Interlocked.Increment(ref _openedHttp20Connections); 231long count = Interlocked.Decrement(ref _openedHttp20Connections); 239Interlocked.Increment(ref _openedHttp30Connections); 246long count = Interlocked.Decrement(ref _openedHttp30Connections);
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.cs (1)
431Interlocked.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) ?? 902Interlocked.CompareExchange(ref _initialSettingsReceived, s_settingsReceivedSingleton, null); 2100if (Interlocked.Read(ref _keepAlivePingPayload) != payload) 2130long 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)
349Exception? firstException = Interlocked.CompareExchange(ref _abortException, abortException, null); 601if (Interlocked.Exchange(ref _haveServerControlStream, true)) 617if (Interlocked.Exchange(ref _haveServerQpackDecodeStream, true)) 628if (Interlocked.Exchange(ref _haveServerQpackEncodeStream, true))
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (2)
1416Http3RequestStream? stream = Interlocked.Exchange(ref _stream, null); 1443Http3RequestStream? stream = Interlocked.Exchange(ref _stream, null);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (5)
100if (!Interlocked.Exchange(ref _disposed, true)) 139return Interlocked.Exchange(ref _readAheadTaskStatus, ReadAheadTask_CompletionReserved) == ReadAheadTask_Started; 198|| Interlocked.Exchange(ref _readAheadTaskStatus, ReadAheadTask_CompletionReserved) == ReadAheadTask_Started; 208Interlocked.Exchange(ref _readAheadTaskStatus, ReadAheadTask_Started) == ReadAheadTask_CompletionReserved) 281return Interlocked.Exchange(ref _readAheadTaskStatus, ReadAheadTask_Completed) == ReadAheadTask_Started;
System\Net\Http\SocketsHttpHandler\HttpConnectionBase.cs (1)
39public 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, true))
System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs (1)
563if (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 ctrSet, true)) 786if (Interlocked.Exchange(ref ctrSet, true))
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)) 74Interlocked.Increment(ref _lookupsRequested); 75Interlocked.Increment(ref _currentLookups); 104Interlocked.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, false)) 325if (Interlocked.Exchange(ref _hasWaiter, false))
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)
815if (Interlocked.Exchange(ref _disposed, true))
System\Net\Quic\QuicListener.cs (4)
184Interlocked.Increment(ref _pendingConnectionsCapacity); 326if (Interlocked.Decrement(ref _pendingConnectionsCapacity) < 0) 333Interlocked.Increment(ref _pendingConnectionsCapacity); 408if (Interlocked.Exchange(ref _disposed, true))
System\Net\Quic\QuicStream.cs (7)
332if (totalCopied > 0 && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) 408if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 428Interlocked.CompareExchange(ref _sendException, exception, null); 495Interlocked.CompareExchange(ref _sendException, exception, null); 496if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0) 576return (_receiveBuffers.HasCapacity() && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) ? QUIC_STATUS_CONTINUE : QUIC_STATUS_SUCCESS; 715if (Interlocked.Exchange(ref _disposed, true))
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)
297if (Interlocked.Increment(ref _aborted) == 1)
System\Net\HttpWebRequest.cs (5)
998if (Interlocked.Exchange(ref _abortCalled, true)) 1128if (Interlocked.Exchange(ref _beginGetRequestStreamCalled, true)) 1150if (Interlocked.Exchange(ref _endGetRequestStreamCalled, true)) 1401if (Interlocked.Exchange(ref _beginGetResponseCalled, true)) 1421if (Interlocked.Exchange(ref _endGetResponseCalled, true))
System\Net\TimerThread.cs (5)
455internal override bool Cancel() => !Interlocked.Exchange(ref _canceled, true); 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 (43)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (3)
108} while (Interlocked.CompareExchange(ref _rentCount, oldCount + 1, oldCount) != oldCount); 115return Interlocked.CompareExchange(ref _rentCount, -1, 0) == 0; 120if (Interlocked.Decrement(ref _rentCount) < 0)
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, true)) 509if (Interlocked.Exchange(ref _writeInProgress, true)) 727if (Interlocked.Exchange(ref _authInProgress, true))
System\Net\Security\NetSecurityTelemetry.cs (21)
53_tlsHandshakeRateCounter ??= new IncrementingPollingCounter("tls-handshake-rate", this, () => Interlocked.Read(ref _finishedTlsHandshakes)) 59_totalTlsHandshakesCounter ??= new PollingCounter("total-tls-handshakes", this, () => Interlocked.Read(ref _finishedTlsHandshakes)) 64_currentTlsHandshakesCounter ??= new PollingCounter("current-tls-handshakes", this, () => -Interlocked.Read(ref _finishedTlsHandshakes) + Interlocked.Read(ref _startedTlsHandshakes)) 69_failedTlsHandshakesCounter ??= new PollingCounter("failed-tls-handshakes", this, () => Interlocked.Read(ref _failedTlsHandshakes)) 74_sessionsOpenCounter ??= new PollingCounter("all-tls-sessions-open", this, () => Interlocked.Read(ref _sessionsOpen)) 79_sessionsOpenTls10Counter ??= new PollingCounter("tls10-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls10)) 84_sessionsOpenTls11Counter ??= new PollingCounter("tls11-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls11)) 89_sessionsOpenTls12Counter ??= new PollingCounter("tls12-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls12)) 94_sessionsOpenTls13Counter ??= new PollingCounter("tls13-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls13)) 135Interlocked.Increment(ref _startedTlsHandshakes); 163Interlocked.Increment(ref _finishedTlsHandshakes); 164Interlocked.Increment(ref _failedTlsHandshakes); 177Interlocked.Increment(ref _finishedTlsHandshakes); 212Interlocked.Increment(ref protocolSessionsOpen); 213Interlocked.Increment(ref _sessionsOpen); 232count = Interlocked.Decrement(ref _sessionsOpenTls10); 236count = Interlocked.Decrement(ref _sessionsOpenTls11); 241count = Interlocked.Decrement(ref _sessionsOpenTls12); 245count = Interlocked.Decrement(ref _sessionsOpenTls13); 251count = Interlocked.Decrement(ref _sessionsOpen);
System\Net\Security\SslStream.cs (2)
731var manager = Interlocked.Exchange(ref field, null) ?? new PoolingPointerMemoryManager(); 746if (Interlocked.Exchange(ref _nestedRead, NestedState.StreamInUse) == NestedState.StreamInUse)
System\Net\Security\SslStream.IO.cs (10)
65if (Interlocked.Exchange(ref _nestedRead, NestedState.StreamDisposed) == NestedState.StreamNotInUse && 66Interlocked.Exchange(ref _nestedAuth, NestedState.StreamDisposed) == NestedState.StreamNotInUse) 80if (Interlocked.Exchange(ref _connectionOpenedStatus, ConnectionStatus.Disposed) == ConnectionStatus.HandshakeCompleted) 152bool connectionOpen = Interlocked.CompareExchange(ref _connectionOpenedStatus, ConnectionStatus.HandshakeCompleted, ConnectionStatus.NoHandshake) == ConnectionStatus.NoHandshake; 194if (Interlocked.CompareExchange(ref _nestedAuth, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse) 200if (Interlocked.CompareExchange(ref _nestedRead, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse) 207if (Interlocked.Exchange(ref _nestedWrite, NestedState.StreamInUse) != NestedState.StreamNotInUse) 291if (Interlocked.Exchange(ref _nestedAuth, NestedState.StreamInUse) == NestedState.StreamInUse) 828if (Interlocked.CompareExchange(ref _nestedRead, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse) 970if (Interlocked.Exchange(ref _nestedWrite, NestedState.StreamInUse) == NestedState.StreamInUse)
System\Net\Security\SslStreamCertificateContext.Linux.cs (1)
35Interlocked.CompareExchange(ref _sslContexts, new(), null);
System.Net.ServerSentEvents (1)
System\Net\ServerSentEvents\SseParser_1.cs (1)
465if (Interlocked.Exchange(ref _used, 1) != 0)
System.Net.Sockets (58)
System\Net\Sockets\NetworkStream.cs (1)
390if (Interlocked.Exchange(ref _disposed, true))
System\Net\Sockets\SafeSocketHandle.cs (1)
57private bool TryOwnClose() => !Interlocked.Exchange(ref _ownClose, true);
System\Net\Sockets\SafeSocketHandle.Unix.cs (1)
106Interlocked.CompareExchange(ref _asyncContext, new SocketAsyncContext(this), null) ??
System\Net\Sockets\Socket.cs (1)
3402if (Interlocked.Exchange(ref _disposed, true))
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) ?? 157State oldState = Interlocked.CompareExchange(ref _state, State.Running, State.Waiting); 185if (state == Interlocked.CompareExchange(ref _state, newState, state)) 221if (state == Interlocked.CompareExchange(ref _state, newState, state)) 258Debug.Assert(!Interlocked.Exchange(ref _callbackQueued, true), $"Unexpected _callbackQueued: {_callbackQueued}");
System\Net\Sockets\SocketAsyncEngine.Unix.cs (5)
113int engineIndex = Math.Abs(Interlocked.Increment(ref s_allocateFromEngine) % s_engines.Length); 207Interlocked.Exchange( 234Interlocked.CompareExchange( 262Interlocked.MemoryBarrier(); 273Interlocked.CompareExchange(
System\Net\Sockets\SocketAsyncEventArgs.cs (4)
503if (Interlocked.CompareExchange(ref _operating, OperationState.Disposed, OperationState.Free) != OperationState.Free) 530OperationState status = Interlocked.CompareExchange(ref _operating, OperationState.Configuring, OperationState.Free); 549OperationState status = Interlocked.CompareExchange(ref _operating, OperationState.InProgress, OperationState.Free); 883public bool ReachedCoordinationPointFirst() => !Interlocked.Exchange(ref _isCompleted, true);
System\Net\Sockets\SocketsTelemetry.cs (15)
86Interlocked.Increment(ref _currentOutgoingConnectAttempts); 147long newCount = Interlocked.Decrement(ref _currentOutgoingConnectAttempts); 164Interlocked.Increment(ref _outgoingConnectionsEstablished); 198Interlocked.Increment(ref _incomingConnectionsEstablished); 212Interlocked.Add(ref _bytesReceived, count); 219Interlocked.Add(ref _bytesSent, count); 225Interlocked.Increment(ref _datagramsReceived); 231Interlocked.Increment(ref _datagramsSent); 266_currentOutgoingConnectAttemptsCounter ??= new PollingCounter("current-outgoing-connect-attempts", this, () => Interlocked.Read(ref _currentOutgoingConnectAttempts)) 270_outgoingConnectionsEstablishedCounter ??= new PollingCounter("outgoing-connections-established", this, () => Interlocked.Read(ref _outgoingConnectionsEstablished)) 274_incomingConnectionsEstablishedCounter ??= new PollingCounter("incoming-connections-established", this, () => Interlocked.Read(ref _incomingConnectionsEstablished)) 278_bytesReceivedCounter ??= new PollingCounter("bytes-received", this, () => Interlocked.Read(ref _bytesReceived)) 282_bytesSentCounter ??= new PollingCounter("bytes-sent", this, () => Interlocked.Read(ref _bytesSent)) 286_datagramsReceivedCounter ??= new PollingCounter("datagrams-received", this, () => Interlocked.Read(ref _datagramsReceived)) 290_datagramsSentCounter ??= new PollingCounter("datagrams-sent", this, () => Interlocked.Read(ref _datagramsSent))
System\Net\Sockets\TCPClient.cs (1)
267if (!Interlocked.Exchange(ref _disposed, true))
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.NonWasm.cs (1)
56if (Interlocked.Exchange(ref s_networkChangeRegistered, true))
System.Net.WebSockets (3)
System\Net\WebSockets\AsyncMutex.cs (3)
64int gate = Interlocked.Decrement(ref _gate); 152Interlocked.Increment(ref m._gate); 193int gate = Interlocked.Increment(ref _gate);
System.Net.WebSockets.Client (4)
System\Net\WebSockets\ClientWebSocket.cs (3)
108switch (Interlocked.CompareExchange(ref _state, InternalState.Connecting, InternalState.Created)) 138if (Interlocked.CompareExchange(ref _state, InternalState.Connected, InternalState.Connecting) != InternalState.Connecting) 195if (Interlocked.Exchange(ref _state, InternalState.Disposed) != InternalState.Disposed)
System\Net\WebSockets\WebSocketHandle.Managed.cs (1)
269if (Interlocked.CompareExchange(ref invokerRef, invoker, null) is not null)
System.Private.CoreLib (226)
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); 281if (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, true))
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); 186if (!Interlocked.Exchange(ref activityToStop.m_stopped, true)) 387uint 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)
2273Interlocked.CompareExchange(ref m_createEventLock, new object(), null); 2529Interlocked.CompareExchange(ref _traceLoggingEventTypes, tlet, null); 4584Interlocked.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)
197Interlocked.CompareExchange(ref s_processPath, GetProcessPath() ?? "", null); 220Interlocked.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); 378Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null); 400Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null); 519Interlocked.CompareExchange<CultureInfo?>(ref _parent, culture, null); 715Interlocked.CompareExchange(ref _numInfo, temp, null); 741Interlocked.CompareExchange(ref _dateTimeInfo, temp, null); 833Interlocked.MemoryBarrier(); 1127cache = Interlocked.CompareExchange(ref s_cachedCulturesByName, cache, null) ?? cache; 1142cache = 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)
353LazyHelper? 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 (2)
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 (2)
293uint versionOrig = Interlocked.CompareExchange(ref pEntry.Version, newVersion, version); 357uint 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\ExceptionServices\ExceptionHandling.cs (1)
26if (Interlocked.CompareExchange(ref s_handler, handler, null) != 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, [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)
104if (Interlocked.CompareExchange(ref _kernelEvent, mre, null) != null) 448ITimer? currentTimer = Interlocked.CompareExchange(ref _timer, timer, null); 562ManualResetEvent? mre = Interlocked.Exchange<ManualResetEvent?>(ref _kernelEvent!, null); 609registrations = Interlocked.CompareExchange(ref _registrations, registrations, null) ?? registrations; 711Interlocked.CompareExchange(ref _state, States.NotifyingState, States.NotCanceledState) == States.NotCanceledState) 741Registrations? registrations = Interlocked.Exchange(ref _registrations, null); 744Interlocked.Exchange(ref _state, States.NotifyingCompleteState); 833Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0); // for safety, prevent reorderings crossing this point and seeing inconsistent state. 1171if (Interlocked.Exchange(ref value, true)) 1179do { sw.SpinOnce(); } while (Interlocked.Exchange(ref value, true));
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)
206return (IntPtr)Interlocked.Exchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value); 224return (UIntPtr)Interlocked.Exchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value); 456return (IntPtr)Interlocked.CompareExchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value, (long)comparand); 475return (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!); 115Interlocked.CompareExchange(ref target, value, null!); 284Interlocked.CompareExchange(ref syncLock, new object(), null) ??
src\libraries\System.Private.CoreLib\src\System\Threading\Lock.cs (6)
488Interlocked.Increment(ref s_contentionCount); 614AutoResetEvent? waitEventBeforeUpdate = Interlocked.CompareExchange(ref _waitEvent, newWaitEvent, null); 845new State(Interlocked.CompareExchange(ref lockObj._state, toState._state, fromState._state)); 883var state = new State(Interlocked.Decrement(ref lockObj._state)); 1003var state = new State(Interlocked.Add(ref lockObj._state, Neg(SpinnerCountIncrement))); 1147var 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) 688if (Interlocked.CompareExchange(ref m_combinedState, newState, oldState) == oldState)
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.cs (1)
466Interlocked.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)
110Interlocked.CompareExchange(ref threadPoolInstance._numThreadsBeingKeptAlive, count + 1, count); 365int prevCount = Interlocked.CompareExchange(ref threadPoolInstance._separated.numRequestedWorkers, count - 1, count);
src\libraries\System.Private.CoreLib\src\System\Threading\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.Exchange(ref _isLocked, true); 1555Interlocked.Add(ref _enterDeprioritizationState, deprioritizationStateChange); 1584Interlocked.Add(ref _enterDeprioritizationState, -deprioritizationStateChange);
src\libraries\System.Private.CoreLib\src\System\Threading\RegisteredWaitHandle.Portable.cs (2)
78Interlocked.Exchange(ref s_cachedEvent, null) ?? 83if (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); 888Interlocked.Increment(ref props.m_completionCountdown); 900Interlocked.Decrement(ref props.m_completionCountdown); 969if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null) 1069if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null) 1171newId = Interlocked.Increment(ref s_taskIdCounter); 1198Interlocked.CompareExchange(ref m_taskId, newId, 0); 1336Interlocked.CompareExchange(ref m_contingentProperties, new ContingentProperties(), null); 1486if (Interlocked.CompareExchange(ref contingentProps.m_completionEvent, newMre, null) != null) 1772if (Interlocked.CompareExchange(ref props.m_exceptionsHolder, holder, null) != null) 2006Interlocked.Decrement(ref props.m_completionCountdown) == 0) // Reaching this sub clause means there may be remaining active children, 2093Interlocked.Exchange(ref m_stateFlags, m_stateFlags | completionState); 2167Interlocked.CompareExchange(ref props.m_exceptionalChildren, new List<Task>(), null); 2184if (Interlocked.Decrement(ref props!.m_completionCountdown) == 0) 2293int prevState = Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled); 3306Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled); 3451object? continuationObject = Interlocked.Exchange(ref m_continuationObject, s_taskCompletionSentinel); 4569oldValue = Interlocked.CompareExchange(ref m_continuationObject, list, expected); 4626if ((m_continuationObject != null) || (Interlocked.CompareExchange(ref m_continuationObject, tc, null) != null)) 4650continuationsLocalRef = Interlocked.CompareExchange(ref m_continuationObject, new List<object?>(), continuationObject); 5145if (Interlocked.Decrement(ref _count) == 0) Set(); 6101object? failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, completedTask, null); 6120failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, new List<Task> { first, completedTask }, first); 6134if (Interlocked.Decrement(ref _remainingToComplete) == 0) 6421if (Interlocked.Decrement(ref m_count) == 0) 6653if ((task1 = Interlocked.Exchange(ref _task1, null)) != null) 6915public 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)
364Interlocked.CompareExchange(ref s_asyncLocalPrincipal, new AsyncLocal<IPrincipal?>(), null); 556public static void MemoryBarrier() => Interlocked.MemoryBarrier(); 670return Interlocked.CompareExchange(ref s_nameToSlotMap, nameToSlotMap, null) ?? nameToSlotMap;
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (19)
41if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues) 81if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues) 265Interlocked.Exchange(ref m_tailIndex, tail); 331Interlocked.Exchange(ref m_headIndex, head + 1); 613if (Interlocked.Exchange( 743workItem = Interlocked.Exchange(ref _nextWorkItemToProcess, null); 762Interlocked.CompareExchange(ref _mayHaveHighPriorityWorkItems, false, true) && 933Interlocked.MemoryBarrier(); 938workItem = Interlocked.Exchange(ref workQueue._nextWorkItemToProcess, null); 970Interlocked.CompareExchange( 990Interlocked.MemoryBarrier(); 1002Interlocked.MemoryBarrier(); 1028Interlocked.CompareExchange( 1319if (Interlocked.Exchange( 1340Interlocked.CompareExchange( 1367Interlocked.MemoryBarrier(); 1378Interlocked.CompareExchange( 1443Interlocked.MemoryBarrier(); // ensure that an old cached value is not read below 1452Debug.Assert(!Interlocked.Exchange(ref _executed, true), "A QueueUserWorkItemCallback was called twice!");
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); 169if (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)
719Interlocked.CompareExchange(ref s_defaultBinder, new DefaultBinder(), null) ??
src\System\Diagnostics\StackFrameHelper.cs (1)
131Interlocked.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); 163Interlocked.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)
1478existingCache = Interlocked.CompareExchange(ref m_cache, newCache, null); 1675Interlocked.CompareExchange(ref s_methodInstantiationsLock!, new object(), null); 2474IntPtr gcHandle = Interlocked.CompareExchange(ref m_cache, newgcHandle, IntPtr.Zero);
src\System\RuntimeType.GenericCache.cs (6)
106if (Interlocked.CompareExchange(ref genericCache, newEntry, existing) == existing) 119if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing) 124if (Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, existingEntry) == existingEntry) 142if (Interlocked.CompareExchange(ref genericCache, newEntry, null) == null) 155if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing) 161TCache? currentEntry = Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, null);
System.Private.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)
171Interlocked.CompareExchange(ref _moreInfo, new MoreInfo(), null); 208Interlocked.Or(ref Unsafe.As<Flags, ulong>(ref _flags), (ulong)flags); 2400Interlocked.CompareExchange(ref _info, info, null!); 2405Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, 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.Windows.Core (2)
Windows\Win32\System\Com\AgileComPointer.cs (1)
141uint cookie = Interlocked.Exchange(ref _cookie, 0);
Windows\Win32\System\Com\GlobalInterfaceTable.UnknownStrategy.cs (1)
30uint cookie = Interlocked.Exchange(ref _cookie, 0);
System.Private.Xml (8)
System\Xml\Schema\Preprocessor.cs (1)
470Interlocked.CompareExchange<XmlSchema?>(ref s_builtInSchemaForXmlNS, tempSchema, null);
System\Xml\Schema\XmlSchema.cs (1)
399_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)
2480Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiTypeSO, tempXsiTypeSO, null); 2488Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiNilSO, tempxsiNilSO, null); 2497Interlocked.CompareExchange<XmlSchemaAttribute?>(ref s_xsiSLSO, tempxsiSLSO, null); 2506Interlocked.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)
449if (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)
271if (Interlocked.Exchange(ref _inCacheManagerThread, 1) != 0) 331Interlocked.Exchange(ref _inCacheManagerThread, 0); 337if (Interlocked.Exchange(ref _disposed, 1) == 0) 342if (timerHandleRef != null && Interlocked.CompareExchange(ref _timerHandleRef, null, timerHandleRef) == timerHandleRef) 385while (Interlocked.Exchange(ref _inCacheManagerThread, 1) != 0) 406Interlocked.Exchange(ref _inCacheManagerThread, 0);
System\Runtime\Caching\MemoryCacheStore.cs (1)
254if (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)
86if (UniqueInstance && !Interlocked.Exchange(ref _released, true))
System.Security.Cryptography (9)
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.Pkcs (2)
System\Security\Cryptography\Pkcs\KeyAgreeRecipientInfo.cs (1)
66Interlocked.MemoryBarrier();
System\Security\Cryptography\Pkcs\Pkcs9SigningTime.cs (1)
50Interlocked.MemoryBarrier();
System.ServiceModel.Syndication (1)
System\ServiceModel\Channels\UriGenerator.cs (1)
21long nextId = Interlocked.Increment(ref _id);
System.ServiceModel.UnixDomainSocket (2)
System\ServiceModel\Channels\SocketAwaitableEventArgs.cs (2)
69if (c != null || (c = Interlocked.CompareExchange(ref _continuation, _continuationCompleted, null)) != null) 116var prevContinuation = Interlocked.CompareExchange(ref _continuation, continuation, 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 (15)
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)
324Interlocked.MemoryBarrier(); 341Interlocked.MemoryBarrier();
System\Text\Json\Nodes\JsonObject.IDictionary.cs (2)
243Interlocked.MemoryBarrier(); 269Interlocked.MemoryBarrier();
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (1)
33return Interlocked.CompareExchange(ref _cachingContext, ctx, null) ?? ctx;
System\Text\Json\Serialization\JsonSerializerOptions.cs (1)
1141return 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\JsonTypeInfo.cs (1)
263JsonPropertyInfoList? result = Interlocked.CompareExchange(ref _properties, list, null);
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.WriteHelpers.cs (2)
374if (Interlocked.Increment(ref _serializationCount) == MinSerializationsSampleSize) 378Interlocked.CompareExchange(ref _canUseSerializeHandlerInStreamingState, 1, 0);
System\Text\Json\Serialization\Metadata\ReflectionEmitCachingMemberAccessor.Cache.cs (1)
44if (Interlocked.CompareExchange(ref _evictLock, 1, 0) == 0)
System.Text.RegularExpressions (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\net10.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)
73TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 74TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 94Interlocked.Increment(ref _successfulLeasesCount); 97Interlocked.Increment(ref _failedLeasesCount); 113Interlocked.Increment(ref _failedLeasesCount); 129Interlocked.Increment(ref _successfulLeasesCount); 171Interlocked.Increment(ref _failedLeasesCount); 179Interlocked.Increment(ref _failedLeasesCount); 203Interlocked.Increment(ref _successfulLeasesCount); 216Interlocked.Increment(ref _successfulLeasesCount); 303Interlocked.Increment(ref _successfulLeasesCount);
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (11)
93TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 94TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 115Interlocked.Increment(ref _successfulLeasesCount); 119Interlocked.Increment(ref _failedLeasesCount); 130Interlocked.Increment(ref _failedLeasesCount); 149Interlocked.Increment(ref _successfulLeasesCount); 189Interlocked.Increment(ref _failedLeasesCount); 197Interlocked.Increment(ref _failedLeasesCount); 230Interlocked.Increment(ref _successfulLeasesCount); 243Interlocked.Increment(ref _successfulLeasesCount); 358Interlocked.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)
107TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 108TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 126Interlocked.Increment(ref _successfulLeasesCount); 130Interlocked.Increment(ref _failedLeasesCount); 142Interlocked.Increment(ref _failedLeasesCount); 161Interlocked.Increment(ref _successfulLeasesCount); 201Interlocked.Increment(ref _failedLeasesCount); 209Interlocked.Increment(ref _failedLeasesCount); 233Interlocked.Increment(ref _successfulLeasesCount); 247Interlocked.Increment(ref _successfulLeasesCount); 371Interlocked.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)
101TotalFailedLeases = Interlocked.Read(ref _failedLeasesCount), 102TotalSuccessfulLeases = Interlocked.Read(ref _successfulLeasesCount), 120Interlocked.Increment(ref _successfulLeasesCount); 124Interlocked.Increment(ref _failedLeasesCount); 135Interlocked.Increment(ref _failedLeasesCount); 154Interlocked.Increment(ref _successfulLeasesCount); 194Interlocked.Increment(ref _failedLeasesCount); 202Interlocked.Increment(ref _failedLeasesCount); 237Interlocked.Increment(ref _successfulLeasesCount); 250Interlocked.Increment(ref _successfulLeasesCount); 372Interlocked.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 (17)
Base\DataflowBlock.cs (6)
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);
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 (15)
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 (3)
119if (Interlocked.CompareExchange(ref state.NextAvailable, element + T.One, element) != element) 571Interlocked.Increment(ref _completionRefCount); 588public bool SignalWorkerCompletedIterating() => Interlocked.Decrement(ref _completionRefCount) == 0;
System\Threading\Tasks\ParallelLoopState.cs (2)
214while (Interlocked.CompareExchange(ref pflags._lowestBreakIteration, iteration, oldLBI) != oldLBI) 318if (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, true); 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.Windows.Forms (5)
System\Windows\Forms\Application.ThreadContext.cs (1)
270if (Interlocked.Exchange(ref _disposed, 1) == 1)
System\Windows\Forms\Rendering\ScreenDcCache.cs (2)
48item = Interlocked.Exchange(ref _itemsCache[i], IntPtr.Zero); 72temp = Interlocked.Exchange(ref _itemsCache[i], temp);
System\Windows\Forms\Screen.cs (2)
189Interlocked.Exchange(ref _currentDesktopChangedCount, DesktopChangedCount); 337Interlocked.Increment(ref s_desktopChangedCount);
System.Windows.Forms.Primitives (4)
System\Windows\Forms\ObjectCache.cs (2)
32item = Interlocked.Exchange(ref _itemsCache[i], null); 51temp = Interlocked.Exchange(ref _itemsCache[i], temp);
System\Windows\Forms\RefCountedCache.CacheEntry.cs (2)
28public void AddRef() => Interlocked.Increment(ref _refCount); 46int refCount = Interlocked.Decrement(ref _refCount);
System.Xaml (19)
System\Xaml\Schema\Reflector.cs (1)
372updated = 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)
172Interlocked.CompareExchange(ref _attachableMemberCache, 243Interlocked.CompareExchange(ref _nonAttachableMemberCache, 296Interlocked.CompareExchange(ref _positionalParameterTypes, 367Interlocked.CompareExchange(ref _aliasedProperties, dict, null);
System\Xaml\Schema\XamlValueConverter.cs (1)
48Interlocked.CompareExchange(ref _instance, CreateInstance(), null);
System\Xaml\XamlMember.cs (1)
856Interlocked.CompareExchange(ref _reflector, reflector, null);
System\Xaml\XamlSchemaContext.cs (10)
357Interlocked.CompareExchange(ref _xmlNsCompatDict, CreateDictionary<string, string>(), null); 482Interlocked.CompareExchange(ref _masterBracketCharacterCache, CreateDictionary<XamlType, Dictionary<string, SpecialBracketCharacters>>(), null); 493Interlocked.CompareExchange(ref _masterTypeList, CreateDictionary<Type, XamlType>(ReferenceEqualityComparer.Instance), null); 504Interlocked.CompareExchange(ref _masterValueConverterList, CreateDictionary<ReferenceEqualityTuple<Type, XamlType, Type>, object>(), null); 515Interlocked.CompareExchange(ref _masterMemberList, CreateDictionary<ReferenceEqualityTuple<MemberInfo, MemberInfo>, XamlMember>(), null); 704Interlocked.CompareExchange(ref _xmlnsInfo, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null); 715Interlocked.CompareExchange(ref _xmlnsInfoForDynamicAssemblies, CreateDictionary<WeakRefKey, XmlNsInfo>(), null); 727Interlocked.CompareExchange(ref _namespaceByUriList, CreateDictionary<string, XamlNamespace>(), null); 742Interlocked.CompareExchange(ref _xmlnsInfoForUnreferencedAssemblies, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null); 1238Interlocked.CompareExchange(ref _referenceAssemblyNames, asmNames, null);
System\Xaml\XamlType.cs (1)
1394Interlocked.CompareExchange(ref _reflector, reflector, null);
UnitTests.Common (2)
TestTypes.cs (2)
293Interlocked.Increment(ref _operationCount); 299Interlocked.Decrement(ref _operationCount) == 0)