RemoveParticipants() public method

Notifies the Barrier that there will be fewer participants.
is less than /// 0. The barrier already has 0 participants. /// The method was invoked from within a post-phase action. /// The current instance has already been /// disposed.
public RemoveParticipants ( int participantCount ) : void
participantCount int The number of additional participants to remove from the barrier.
return void
コード例 #1
0
ファイル: BarrierTests.cs プロジェクト: modulexcite/IL2JS
        /// <summary>
        /// Test RemoveParticipants
        /// </summary>
        /// <param name="initialCount">The initial barrier participants count</param>
        /// <param name="participantsToRemove">The aprticipants that will be added</param>
        /// <param name="exceptionType">Type of the exception in case of invalid input, null for valid cases</param>
        /// <returns>Tru if the test succeeded, false otherwise</returns>
        private static bool RunBarrierTest5_RemoveParticipants(int initialCount, int participantsToRemove, Type exceptionType)
        {
            TestHarness.TestLog("RemoveParticipants(" + initialCount + "," + participantsToRemove + ")");
            Barrier b = new Barrier(initialCount);
            Exception exception = null;
            try
            {
                b.RemoveParticipants(participantsToRemove);
                if (b.ParticipantCount != initialCount - participantsToRemove)
                {
                    TestHarness.TestLog("RemoveParticipants failed, total participant was not decreased");
                    return false;
                }

            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null && exceptionType == null)
            {
                TestHarness.TestLog("RemoveParticipants failed, unexpected exception has been thrown.");
                return false;
            }
            if (exception != null && !Type.Equals(exceptionType, exception.GetType()))
            {
                TestHarness.TestLog("RemoveParticipants failed, exceptions types do not match.");
                return false;
            }
            TestHarness.TestLog("RemoveParticipants succeeded");
            return true;
        }