System.Threading.Barrier.WaitCurrentPhase C# (CSharp) Méthode

WaitCurrentPhase() private méthode

Wait until the current phase finishes completely by spinning until either the event is set, or the phase count is incremented more than one time
private WaitCurrentPhase ( ManualResetEventSlim currentPhaseEvent, long observedPhase ) : void
currentPhaseEvent ManualResetEventSlim The current phase event
observedPhase long The current phase for that thread
Résultat void
        private void WaitCurrentPhase(ManualResetEventSlim currentPhaseEvent, long observedPhase)
        {
            //spin until either of these two conditions succeeds
            //1- The event is set
            //2- the phase count is incremented more than one time, this means the next phase is finished as well,
            //but the event will be reset again, so we check the phase count instead
            SpinWait spinner = new SpinWait();
            while (!currentPhaseEvent.IsSet && CurrentPhaseNumber - observedPhase <= 1)
            {
                spinner.SpinOnce();
            }
        }