6 [__DynamicallyInvokable]
7 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
10 internal const int YIELD_THRESHOLD = 10;
12 internal const int SLEEP_0_EVERY_HOW_MANY_TIMES = 5;
14 internal const int SLEEP_1_EVERY_HOW_MANY_TIMES = 20;
20 [__DynamicallyInvokable]
23 [__DynamicallyInvokable]
32 [__DynamicallyInvokable]
35 [__DynamicallyInvokable]
40 return PlatformHelper.IsSingleProcessor;
47 [__DynamicallyInvokable]
52 CdsSyncEtwBCLProvider.Log.SpinWait_NextSpinWillYield();
53 int num = (m_count >= 10) ? (m_count - 10) : m_count;
58 else if (num % 5 == 4)
71 m_count = ((m_count ==
int.MaxValue) ? 10 : (m_count + 1));
75 [__DynamicallyInvokable]
84 [__DynamicallyInvokable]
97 [__DynamicallyInvokable]
101 if (num < -1 || num >
int.MaxValue)
115 [__DynamicallyInvokable]
116 public static bool SpinUntil(Func<bool> condition,
int millisecondsTimeout)
118 if (millisecondsTimeout < -1)
122 if (condition ==
null)
127 if (millisecondsTimeout != 0 && millisecondsTimeout != -1)
129 num = TimeoutHelper.GetTime();
134 if (millisecondsTimeout == 0)
139 if (millisecondsTimeout != -1 && spinWait.
NextSpinWillYield && millisecondsTimeout <= TimeoutHelper.GetTime() - num)
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
void Reset()
Resets the spin counter.
Provides support for spin-based waiting.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
bool NextSpinWillYield
Gets whether the next call to M:System.Threading.SpinWait.SpinOnce will yield the processor,...
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
static void SpinUntil(Func< bool > condition)
Spins until the specified condition is satisfied.
void SpinOnce()
Performs a single spin.
int Count
Gets the number of times M:System.Threading.SpinWait.SpinOnce has been called on this instance.
Represents a time interval.To browse the .NET Framework source code for this type,...
static bool SpinUntil(Func< bool > condition, int millisecondsTimeout)
Spins until the specified condition is satisfied or until the specified timeout is expired.
static void Sleep(int millisecondsTimeout)
Suspends the current thread for the specified number of milliseconds.
static bool Yield()
Causes the calling thread to yield execution to another thread that is ready to run on the current pr...
static bool SpinUntil(Func< bool > condition, TimeSpan timeout)
Spins until the specified condition is satisfied or until the specified timeout is expired.
static void SpinWait(int iterations)
Causes a thread to wait the number of times defined by the iterations parameter.
Creates and controls a thread, sets its priority, and gets its status.