Repository navigation
Activity Parallel Activity Node
A Parallel Activity Node runs a nested Activity concurrently for partitions of its incoming tokens. AddParallelActivity<TToken>(..., chunkSize) selects tokens of type TToken and creates one nested execution per chunk. Use it for independent work; coordinate any shared external state in application code.
flowchart LR
load(Load images) -->|Image tokens| parallel{{Parallel Activity}}
subgraph body["Concurrent nested executions"]
input["Input boundary"] --> resize(Resize image)
resize --> output["Output boundary"]
end
parallel -->|Resized images| save(Save results)
Mermaid approximation: this diagram shows the model's routing, not a complete UML Activity notation. Rounded boxes represent actions; edge labels identify token types or guards. Input/Output boxes name Stateflows boundary APIs, not UML final nodes or a claim that UML uses these box labels. Mermaid does not model pins, activity parameters, or expansion regions natively.
.AddInitial(initial => initial.AddControlFlow("LoadImages"))
.AddAction(
"LoadImages",
async c => c.OutputRange(await images.LoadAsync(c.CancellationToken)),
node => node.AddFlow<Image>("Resize"))
.AddParallelActivity<Image>("Resize", nested => nested
.AddInput(input => input.AddFlow<Image>("ResizeOne"))
.AddInitial(initial => initial.AddControlFlow("ResizeOne"))
.AddAction(
"ResizeOne",
async c => c.Output(await imageProcessor.ResizeAsync(
c.GetTokensOfType<Image>().Single(), c.CancellationToken)),
node => node.AddFlow<Image, OutputNode>())
.AddOutput()
.AddFlow<Image>("Save"),
chunkSize: 1)
.AddAction("Save", async c =>
await images.SaveAsync(c.GetTokensOfType<Image>(), c.CancellationToken))The default chunk size is one token. A larger chunk gives one nested execution multiple selected tokens. Each concurrent execution receives a distinct token partition; capture shared mutable state safely and ensure downstream services support concurrent calls. Values are returned to the parent only through an inner OutputNode and AddOutput(). Without that boundary output, use the node for parallel side effects.
Unlike Iterative Activity Node, this node runs chunks concurrently. See also Structured Activity Node.
Home page Support Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0. © by Mikołaj Milewski, 2026
Overview
Installation
Runtimes
Orleans runtime
Concepts
Events and Structural Events
Messaging Patterns
Validation
Scheduling
Observability
Behaviors
Behavior Values
Dependency Injection
Behavioral Groups
State Machines
Concepts
State Identity
In-State Event Deferrals
Evaluation of Transitions
Exception Handling
Building blocks
Regions
States
State
Composite State
Orthogonal State
Final State
Pseudostates
Choice
Junction
Fork
Join
History
Transitions
Transition
Default Transition
Internal Transition
Activities
Concepts
Exception Handling
Implicit Fork and Join
Tokens
Building blocks
Nodes
Action Node
Decision Node
Merge Node
Initial Node
Final Node
Input Node
Output Node
Fork Node
Join Node
Accept Event Action Node
Send Event Action Node
Publish Event Action Node
Time Event Action Node
Data Store Node
Structured Activity Node
Iterative Activity Node
Parallel Activity Node
Flows
Data Flow
Control Flow
Actions
Entities
Fields
Mutations
Projections
Extensions
ClearScript
FluentValidation
JSON definitions
Minimal APIs
OneOf
OpenTelemetry
PlantUML
Scheduling