At the beginning of this chapter, we mentioned that spinning is much more efficient than blocking for smaller waits. Spinning has fewer kernel overheads related to context switching and transitioning.
We can create a SpinWait object as follows:
var spin = new SpinWait();
Then, wherever we need to make a spin, we can just call the following command:
spin.SpinOnce();