Barrier 构造函数

定义

初始化 Barrier 类的新实例。Initializes a new instance of the Barrier class.

重载

Barrier(Int32)

初始化 Barrier 类的新实例。Initializes a new instance of the Barrier class.

Barrier(Int32, Action<Barrier>)

初始化 Barrier 类的新实例。Initializes a new instance of the Barrier class.

Barrier(Int32)

初始化 Barrier 类的新实例。Initializes a new instance of the Barrier class.

public:
 Barrier(int participantCount);
public Barrier (int participantCount);
new System.Threading.Barrier : int -> System.Threading.Barrier
Public Sub New (participantCount As Integer)

参数

participantCount
Int32

参与线程的数量。The number of participating threads.

例外

participantCount 小于 0 或大于 32,767。participantCount is less than 0 or greater than 32,767.

适用于

Barrier(Int32, Action<Barrier>)

初始化 Barrier 类的新实例。Initializes a new instance of the Barrier class.

public:
 Barrier(int participantCount, Action<System::Threading::Barrier ^> ^ postPhaseAction);
public Barrier (int participantCount, Action<System.Threading.Barrier> postPhaseAction);
public Barrier (int participantCount, Action<System.Threading.Barrier>? postPhaseAction);
new System.Threading.Barrier : int * Action<System.Threading.Barrier> -> System.Threading.Barrier
Public Sub New (participantCount As Integer, postPhaseAction As Action(Of Barrier))

参数

participantCount
Int32

参与线程的数量。The number of participating threads.

postPhaseAction
Action<Barrier>

在每个阶段后执行 Action<T>The Action<T> to be executed after each phase. 可传递 NULL(在 Visual Basic 中为 Nothing)以执行未执行任何操作。null (Nothing in Visual Basic) may be passed to indicate no action is taken.

例外

participantCount 小于 0 或大于 32,767。participantCount is less than 0 or greater than 32,767.

注解

postPhaseAction委托将在所有参与者在一个阶段到达关卡后执行。The postPhaseAction delegate will be executed after all participants have arrived at the barrier in one phase. 在 postPhaseAction 委托执行完毕之前,不会将参与者发布到下一阶段。The participants will not be released to the next phase until the postPhaseAction delegate has completed execution.

适用于