system\diagnostics\eventing\eventsource.cs (5)
1266Interlocked.CompareExchange(ref m_eventData[eventId].TraceLoggingEventTypes, tlet, null);
1991Interlocked.CompareExchange(ref m_eventData[eventId].TraceLoggingEventTypes, tlet, null);
2071Interlocked.CompareExchange(ref m_eventData[eventId].TraceLoggingEventTypes, eventTypes, null);
4580Interlocked.CompareExchange(ref s_EventSources, new List<WeakReference>(2), null);
5442while (Interlocked.CompareExchange(ref af.m_curSampleCount, newSampleCount, curSampleCount) != curSampleCount);
system\io\unmanagedmemorystream.cs (29)
313return Interlocked.Read(ref _length);
328return Interlocked.Read(ref _position);
344Interlocked.Exchange(ref _position, value);
357long pos = Interlocked.Read(ref _position);
377Interlocked.Exchange(ref _position, value - _mem);
408long pos = Interlocked.Read(ref _position);
409long len = Interlocked.Read(ref _length);
441Interlocked.Exchange(ref _position, pos + n);
481long pos = Interlocked.Read(ref _position); // Use a local to avoid a race condition
482long len = Interlocked.Read(ref _length);
485Interlocked.Exchange(ref _position, pos + 1);
518Interlocked.Exchange(ref _position, offset);
522long pos = Interlocked.Read(ref _position);
525Interlocked.Exchange(ref _position, offset + pos);
529long len = Interlocked.Read(ref _length);
532Interlocked.Exchange(ref _position, len + offset);
539long finalPos = Interlocked.Read(ref _position);
557long pos = Interlocked.Read(ref _position);
558long len = Interlocked.Read(ref _length);
564Interlocked.Exchange(ref _length, value);
566Interlocked.Exchange(ref _position, value);
585long pos = Interlocked.Read(ref _position); // Use a local to avoid a race condition
586long len = Interlocked.Read(ref _length);
607Interlocked.Exchange(ref _length, n);
637Interlocked.Exchange(ref _position, n);
678long pos = Interlocked.Read(ref _position); // Use a local to avoid a race condition
679long len = Interlocked.Read(ref _length);
700Interlocked.Exchange(ref _length, n);
724Interlocked.Exchange(ref _position, n);
system\runtime\remoting\identity.cs (7)
256if(currentFlags == Interlocked.CompareExchange(ref _flags, newFlags, currentFlags))
268if(currentFlags == Interlocked.CompareExchange(ref _flags, newFlags, currentFlags))
299if(currentFlags == Interlocked.CompareExchange(ref _flags, newFlags, currentFlags))
363Interlocked.CompareExchange(ref _tpOrObject, tpObj, null);
385Interlocked.CompareExchange(ref _objRef, objRefGiven, null);
405Interlocked.CompareExchange(
445Interlocked.CompareExchange(
system\threading\CancellationTokenSource.cs (9)
189if (Interlocked.CompareExchange(ref m_kernelEvent, mre, null) != null)
487if (Interlocked.CompareExchange(ref m_timer, newTimer, null) != null)
675registeredCallbacksLists = Interlocked.CompareExchange(ref m_registeredCallbacksLists, list, null);
684Interlocked.CompareExchange(ref (registeredCallbacksLists[myIndex]), callBackArray, null);
723if (Interlocked.CompareExchange(ref m_state, NOTIFYING, NOT_CANCELED) == NOT_CANCELED)
765Interlocked.Exchange(ref m_state, NOTIFYINGCOMPLETE);
1122if (curr.m_elements[tryIndex] == null && Interlocked.CompareExchange(ref curr.m_elements[tryIndex], element, null) == null)
1140if (Interlocked.CompareExchange(ref tail.m_next, newTail, null) == null)
1226T prevailingValue = Interlocked.CompareExchange(ref m_elements[index], null, expectedElement);
system\threading\SpinLock.cs (11)
170Interlocked.CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) //acquiring the lock failed
270Interlocked.CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) // acquiring the lock failed
350if (Interlocked.CompareExchange(ref m_owner, observedOwner | 1, observedOwner, ref lockTaken) == observedOwner)
363turn = (Interlocked.Add(ref m_owner, 2) & WAITERS_MASK) >> 1 ;
406if (Interlocked.CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
448if (Interlocked.CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
500if (Interlocked.CompareExchange(ref m_owner, observedOwner - 2, observedOwner) == observedOwner)
552if (Interlocked.CompareExchange(ref m_owner, m_newOwner, lockUnowned, ref lockTaken) == lockUnowned)
590Interlocked.Decrement(ref m_owner);
652Interlocked.Exchange(ref m_owner, LOCK_UNOWNED);
654Interlocked.Decrement(ref m_owner);
system\threading\Tasks\Task.cs (24)
820if (Interlocked.CompareExchange(ref m_stateFlags, oldFlags | newBits, oldFlags) == oldFlags)
835if (Interlocked.CompareExchange(ref m_stateFlags, oldFlags | newBits, oldFlags) == oldFlags)
871if (Interlocked.CompareExchange(ref m_stateFlags, newFlags, oldFlags) == oldFlags) break;
1018Interlocked.Increment(ref props.m_completionCountdown);
1030Interlocked.Decrement(ref props.m_completionCountdown);
1099if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1201if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1307newId = Interlocked.Increment(ref s_taskIdCounter);
1332Interlocked.CompareExchange(ref m_taskId, newId, 0);
1674if (Interlocked.CompareExchange(ref contingentProps.m_completionEvent, newMre, null) != null)
2032if (Interlocked.CompareExchange(ref props.m_exceptionsHolder, holder, null) != null)
2231Interlocked.Decrement(ref props.m_completionCountdown) == 0) // Reaching this sub clause means there may be remaining active children,
2323Interlocked.Exchange(ref m_stateFlags, m_stateFlags | completionState);
2383Interlocked.CompareExchange(ref props.m_exceptionalChildren, new List<Task>(), null);
2401if (Interlocked.Decrement(ref props.m_completionCountdown) == 0)
2760int prevState = Interlocked.Exchange(ref m_stateFlags, m_stateFlags | TASK_STATE_CANCELED);
3547Interlocked.Exchange(ref m_stateFlags, m_stateFlags | TASK_STATE_CANCELED);
3597object continuationObject = Interlocked.Exchange(ref m_continuationObject, s_taskCompletionSentinel);
4743Interlocked.CompareExchange(ref m_continuationObject, newList, oldValue);
4800if ((m_continuationObject != null) || (Interlocked.CompareExchange(ref m_continuationObject, tc, null) != null))
4825if (Interlocked.CompareExchange(ref m_continuationObject, new List<object>(), continuationObject) != continuationObject)
5235if (Interlocked.Decrement(ref _count) == 0) Set();
6129if (Interlocked.Decrement(ref m_count) == 0)
6373if (Interlocked.Decrement(ref m_count) == 0)
system\threading\threadpool.cs (10)
309Interlocked.Exchange(ref m_tailIndex, tail);
382Interlocked.Exchange(ref m_headIndex, head + 1);
462int prevIndexes = Interlocked.CompareExchange(ref indexes, newIndexes, oldIndexes);
583int prev = Interlocked.CompareExchange(ref numOutstandingThreadRequests, count+1, count);
605int prev = Interlocked.CompareExchange(ref numOutstandingThreadRequests, count - 1, count);
634Interlocked.CompareExchange(ref head.Next, new QueueSegment(), null);
638Interlocked.CompareExchange(ref queueHead, head.Next, head);
684Interlocked.CompareExchange(ref queueTail, tail.Next, tail);
1005if (Interlocked.CompareExchange(ref m_lock, 1, 0) == 0)
1074if (Interlocked.CompareExchange(ref m_lock, 1, 0) == 0)
net\System\Net\_ConnectStream.cs (20)
173Interlocked.CompareExchange<Exception>(ref m_ErrorException, new IOException(SR.GetString(SR.net_io_readfailure, SR.GetString(SR.net_io_connectionclosed))), null);
389if ( Interlocked.Increment( ref m_DoneCalled) == 1 )
621Interlocked.CompareExchange(ref m_CallNesting, Nesting.InternalIO, Nesting.Idle);
693Interlocked.CompareExchange(ref m_CallNesting, Nesting.Idle, Nesting.InternalIO);
921int nesting = Interlocked.CompareExchange(ref m_CallNesting, Nesting.IoInProgress, Nesting.Idle);
1161nesting = Interlocked.CompareExchange(ref m_CallNesting, (nesting == Nesting.InError? Nesting.InError: Nesting.Idle), Nesting.IoInProgress);
1264Interlocked.CompareExchange<Exception>(ref m_ErrorException, userException, null);
1276int result = Interlocked.CompareExchange(ref m_CallNesting, value, comparand);
1408int nesting = Interlocked.CompareExchange(ref m_CallNesting, Nesting.IoInProgress, Nesting.Idle);
1437Interlocked.CompareExchange(ref m_CallNesting, Nesting.Idle, Nesting.IoInProgress);
1679int nesting = Interlocked.CompareExchange(ref m_CallNesting, Nesting.IoInProgress, Nesting.Idle);
1997Interlocked.CompareExchange(ref m_CallNesting, Nesting.Idle, Nesting.IoInProgress);
2181Interlocked.CompareExchange(ref m_CallNesting, Nesting.InternalIO, Nesting.Idle);
2229Interlocked.CompareExchange(ref m_CallNesting, Nesting.Idle, Nesting.InternalIO);
2521if (Interlocked.Exchange(ref m_ShutDown, AlreadyAborted) >= AlreadyAborted) {
2529if (Interlocked.Increment(ref m_ShutDown) > 1) {
2544if (Interlocked.Exchange(ref m_CallNesting, nesting) == Nesting.IoInProgress)
2690if (!aborting && Interlocked.Exchange(ref m_ShutDown, AlreadyAborted) >= AlreadyAborted){
3038Interlocked.CompareExchange<Exception>(ref m_ErrorException, new IOException(Msg), null);
3042willThrow &= Interlocked.CompareExchange<Exception>(ref m_ErrorException, exception, null) != null;
net\System\Net\HttpWebRequest.cs (9)
2109object returnResult = Interlocked.Exchange(ref m_PendingReturnResult, DBNull.Value);
2340object oldResult = Interlocked.CompareExchange(ref m_PendingReturnResult, pendResult, null);
2361object oldResult = Interlocked.CompareExchange(ref m_PendingReturnResult, NclConstants.Sentinel, null);
3140if(Interlocked.CompareExchange(ref m_Aborted, abortState, 0) == 0) // public abort will never drain streams
3528object responseData = Async? Interlocked.CompareExchange(ref _CoreResponse, null, DBNull.Value): _CoreResponse;
3578object responseData = Interlocked.CompareExchange(ref _CoreResponse, responseOrException, DBNull.Value);
3672responseData = Interlocked.CompareExchange(ref _CoreResponse, responseOrException, null);
6299return (Interlocked.Increment(ref s_UniqueGroupId)).ToString(NumberFormatInfo.InvariantInfo);
6416Interlocked.Exchange(ref isAborted, 1);
net\System\Net\Internal.cs (7)
407Interlocked.CompareExchange(ref _LocalAddressesLock, new object(), null);
466int gate = Interlocked.CompareExchange(ref m_State, Triggered, Open);
483int gate = Interlocked.CompareExchange(ref m_State, Triggering, Open);
495int gate = Interlocked.CompareExchange(ref m_State, Triggered, Triggering);
511int gate = Interlocked.CompareExchange(ref m_State, Signaling, Triggered);
524int gate = Interlocked.CompareExchange(ref m_State, Signaled, Signaling);
535int gate = Interlocked.CompareExchange(ref m_State, Completed, Signaled);
net\System\Net\SecureProtocols\_SslState.cs (12)
173targetHost = "?" + Interlocked.Increment(ref UniqueNameInteger).ToString(NumberFormatInfo.InvariantInfo);
396Interlocked.CompareExchange<_SslStream>(ref _SecureStream, new _SslStream(this), null);
561if (Interlocked.Exchange(ref _NestedAuth, 1) == 1) {
705if (Interlocked.Exchange(ref _NestedAuth, 0) == 0)
1127int lockState = Interlocked.Exchange(ref _LockReadState, LockHandshake);
1155int lockState = Interlocked.Exchange(ref _LockReadState, newState);
1187int lockState = Interlocked.CompareExchange(ref _LockReadState, LockRead, LockNone);
1235int lockState = Interlocked.CompareExchange(ref _LockReadState, LockNone, LockRead);
1267int lockState = Interlocked.CompareExchange(ref _LockWriteState, LockWrite, LockNone);
1302int lockState = Interlocked.CompareExchange(ref _LockWriteState, LockNone, LockWrite);
1359int lockState = Interlocked.Exchange(ref _LockWriteState, LockHandshake);
1394int lockState = Interlocked.CompareExchange(ref _LockWriteState, LockNone, LockHandshake);
net\System\Net\Sockets\Socket.cs (18)
2742if (Interlocked.Exchange(ref asyncConnectOperationLock, 1) != 0)
2784Interlocked.Exchange(ref asyncConnectOperationLock, 0);
2915if (Interlocked.Exchange(ref m_RegisteredWait, null) == null)
3100if (Interlocked.Exchange(ref asyncConnectOperationLock, 1) != 0)
3114Interlocked.Exchange(ref asyncConnectOperationLock, 0);
3169if (Interlocked.Exchange(ref asyncConnectOperationLock, 1) != 0)
3194Interlocked.Exchange(ref asyncConnectOperationLock, 0);
3338Interlocked.Exchange(ref asyncConnectOperationLock, 0);
5675Interlocked.CompareExchange(ref s_InternalSyncObject, o, null);
5802Interlocked.CompareExchange(ref m_AcceptQueueOrConnectResult, new Queue(16), null);
6253while ((last = Interlocked.CompareExchange(ref m_IntCleanedUp, 1, 0)) == 2)
7524Interlocked.CompareExchange<ManualResetEvent>(ref m_AsyncEvent, new ManualResetEvent(false), null);
7532if (Interlocked.CompareExchange(ref m_IntCleanedUp, 2, 0) != 0)
7548Interlocked.Exchange(ref m_IntCleanedUp, 0);
7594if (Interlocked.Exchange(ref me.m_RegisteredWait, null) != null)
8966if(Interlocked.CompareExchange(ref m_Operating, Disposed, Free) != Free) {
8986int status = Interlocked.CompareExchange(ref m_Operating, Configuring, Free);
9001if(Interlocked.CompareExchange(ref m_Operating, InProgress, Free) != Free) {
fx\src\data\System\Data\SqlClient\SqlDataReader.cs (8)
75internal readonly int ObjectID = System.Threading.Interlocked.Increment(ref _objectTypeCount);
3953Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4021Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4113Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4264Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4384Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4485Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
4659Task current = Interlocked.CompareExchange(ref _currentTask, null, source.Task);
System\ServiceModel\Channels\WebSocketTransportDuplexSessionChannel.cs (7)
378if (Interlocked.CompareExchange(ref this.cleanupStatus, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
563if (Interlocked.CompareExchange(ref this.asyncReceiveState, AsyncReceiveState.Cancelled, AsyncReceiveState.Started) == AsyncReceiveState.Started)
836int currentState = Interlocked.CompareExchange(ref this.asyncReceiveState, AsyncReceiveState.Started, AsyncReceiveState.Finished);
921if (Interlocked.CompareExchange(ref this.asyncReceiveState, AsyncReceiveState.Finished, AsyncReceiveState.Started) == AsyncReceiveState.Started)
1379if (Interlocked.CompareExchange(ref this.endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
1457if (Interlocked.CompareExchange(ref this.messageSourceCleanState, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
1495if (Interlocked.CompareExchange(ref this.endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)