SpinWait Structure
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Provides support for spin-based waiting.
Assembly: mscorlib (in mscorlib.dll)
The SpinWait type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of times SpinOnce has been called on this instance. |
![]() | NextSpinWillYield | Gets whether the next call to SpinOnce will yield the processor, triggering a forced context switch. |
| Name | Description | |
|---|---|---|
![]() | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Reset | Resets the spin counter. |
![]() | SpinOnce | Performs a single spin. |
![]() ![]() | SpinUntil(Func<Boolean>) | Spins until the specified condition is satisfied. |
![]() ![]() | SpinUntil(Func<Boolean>, Int32) | Spins until the specified condition is satisfied or until the specified timeout is expired. |
![]() ![]() | SpinUntil(Func<Boolean>, TimeSpan) | Spins until the specified condition is satisfied or until the specified timeout is expired. |
![]() | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.) |
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.
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 Monitor. For most purposes where spin waiting is required, however, the SpinWait type should be preferred over the SpinWait method.



