限制并行 ForEach

ThrottleParallelForEach 活动类似于 ParallelForEach<T> 活动,不同之处在于前者允许设置并发系数来限制要执行的并发分支的数目。 ThrottleParallelForEach 活动派生自 NativeActivity,因为该活动需要对其他活动(子活动)进行计划,并且只有通过 NativeActivityContext 类才能对此进行访问。

项目

ThrottledParallelForEach 示例包含以下项目。

ProjectName 说明 主要文件
ThrottledParallelForEach 包含 ThrottledParallelForEach 活动及其设计器。 ThrottledParallelForEach.cs

ThrottledParallelForEach 活动定义。
CodeTestClient 示例客户端应用程序,通过使用命令性代码的 ThrottledParallelForEach 来配置和运行工作流。 Program.cs

定义和运行示例工作流的实例。

使用此示例

  1. 使用 Visual Studio 打开 ThrottledParallelForEach.sln 文件。

  2. 要生成解决方案,按 Ctrl+Shift+B。

  3. 若要运行解决方案,请按 F5。