SpinWait.SpinOnce Method

Definition

Overloads

SpinOnce()

Performs a single spin.

SpinOnce(Int32)

Performs a single spin and calls Sleep(Int32) after a minimum spin count.

SpinOnce()

Source:
SpinWait.cs
Source:
SpinWait.cs
Source:
SpinWait.cs

Performs a single spin.

C#
public void SpinOnce();

Remarks

This method is typically called in a loop and may change in behavior based on the number of times SpinOnce has been called so far on this instance. Each spin results in the SpinWait method being called. A count is kept of the number of times SpinOnce is called, and after a threshold count is reached, the Yield method is called.

See also

Applies to

.NET 10 ja muud versioonid
Toode Versioonid
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

SpinOnce(Int32)

Source:
SpinWait.cs
Source:
SpinWait.cs
Source:
SpinWait.cs

Performs a single spin and calls Sleep(Int32) after a minimum spin count.

C#
public void SpinOnce(int sleep1Threshold);

Parameters

sleep1Threshold
Int32

A minimum spin count after which Thread.Sleep(1) may be used. A value of -1 disables the use of Thread.Sleep(1).

Exceptions

sleep1Threshold is less than -1.

Remarks

This method is typically called in a loop and may change in behavior based on the number of times SpinOnce() has been called so far on this instance.

Applies to

.NET 10 ja muud versioonid
Toode Versioonid
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10