Skip to content

Activity Flows

Mikołaj Milewski edited this page Oct 27, 2026 · 1 revision

Flows

A UML Activity Flow is a directed edge between Activity nodes. In Stateflows, a flow determines when its target can run and, for object flows, which tokens are offered to it. Flows are declared on their source node with AddControlFlow(...) or AddFlow<TToken>(...).

Flow kinds

Kind Carries Typical use
Control flow A control token, not application data Enable a target action or control node
Object flow Values of a declared token type Move application data between nodes
Transformation flow Input values transformed to another type Convert data while it traverses an edge

Guards, transformations, and weights

Object-flow guards inspect one token and decide whether that token traverses the edge. A transformation can replace it with another token type. SetWeight(n) sets the number of eligible tokens required on that flow before its target can activate.

.AddAction(
    "CreateRequest",
    async c => c.Output(new Request("ORD-42", 125)),
    b => b.AddFlow<Request>("Validate", flow => flow
        .AddGuard(async c => c.Token.Amount > 0)
        .AddTransformation(async c => c.Token.OrderId))
)
.AddAction(
    "Validate",
    async c =>
    {
        foreach (var orderId in c.GetTokensOfType<string>())
        {
            // Continue processing the validated order identifier.
        }
    })

Use a control flow when only execution order matters. Use an object flow when the target needs typed data. Its generic token type selects source tokens; a transformation can change the type delivered to the target.

Execution and token consumption

Flows do not all mean "run the target once for every edge." Nodes activate according to their incoming-flow rules and options. By default, Action nodes use implicit join and fork behavior; explicit Join, Merge, and Fork nodes make synchronization and branching visible in the graph. See Control Flow, Data Flow, and Implicit Fork and Join.

Related pages

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

Clone this wiki locally