Description

The System.Threading.Interlocked methods protect against errors that can occur when the scheduler switches contexts while a thread is updating a variable that can be accessed by other threads. The members of this class do not throw exceptions.

[Note: The System.Threading.Interlocked.Increment method and its counterpart, System.Threading.Interlocked.Decrement, increment or decrement a variable and store the resulting value as an atomic operation. The System.Threading.Interlocked.Exchange method atomically exchanges the values of the specified variables. The System.Threading.Interlocked.CompareExchange method provides an atomic operation that compares two values and stores a third value in one of the variables, based on the outcome ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.