本文整理汇总了C#中System.Threading.Barrier.RemoveParticipants方法的典型用法代码示例。如果您正苦于以下问题:C# Barrier.RemoveParticipants方法的具体用法?C# Barrier.RemoveParticipants怎么用?C# Barrier.RemoveParticipants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Barrier
的用法示例。
在下文中一共展示了Barrier.RemoveParticipants方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunBarrierTest5_RemoveParticipants
/// <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;
}