System.Threading.SpinWait Structure

Provides support for spin-based waiting.

See Also: SpinWait Members


public struct SpinWait


System.Threading.SpinWait encapsulates common spinning logic. On single-processor machines, yields are always used instead of busy waits, and on computers with Intel processors employing Hyper-Threading technology, it helps to prevent hardware thread starvation. SpinWait encapsulates a good mixture of spinning and true yielding.

System.Threading.SpinWait is a value type, which means that low-level code can utilize SpinWait without fear of unnecessary allocation overheads. SpinWait is not generally useful for ordinary applications. In most cases, you should use the synchronization classes provided by the .NET Framework, such as System.Threading.Monitor. For most purposes where spin waiting is required, however, the System.Threading.SpinWait type should be preferred over the Thread.SpinWait(int) method.


Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: