<PackageReference Include="NUnit" Version="3.10.0" />

SpinWait

public struct SpinWait
Provides support for spin-based waiting.
public int Count { get; }

Gets the number of times SpinOnce has been called on this instance.

public bool NextSpinWillYield { get; }

Gets whether the next call to SpinOnce will yield the processor, triggering a forced context switch.

public static void SpinUntil(Func<bool> condition)

Spins until the specified condition is satisfied.

public static bool SpinUntil(Func<bool> condition, TimeSpan timeout)

Spins until the specified condition is satisfied or until the specified timeout is expired.

public static bool SpinUntil(Func<bool> condition, int millisecondsTimeout)

Spins until the specified condition is satisfied or until the specified timeout is expired.

public void Reset()

Resets the spin counter.

public void SpinOnce()

Performs a single spin.