Repository navigation
State Machine Final State
Final State represents stable configuration of State Machine. There can be exactly one Final State per Region (if Final State is a substate of Composite State or Orthogonal State) or exactly one per State Machine (if Final State is defined on State Machine's main level).
Final State can't have any outgoing Transitions and, when reached, cannot be exited explicitly. It can be exited only implicitly when parent State is exited.
Final State can't define any OnEntry / OnExit logic.
Outcome of reaching Final State differs depending on its owner:
- Composite States and Orthogonal States are finalized when Final States in all their Regions are reached,
- State Machine Behavior is finalized when Final State that is a direct child of a State Machine is reached.
Final State consist of:
- Name, uniquely identifying Final State within State Machine,
- Parent State, if Final State is a substate of Composite State or Orthogonal State.
In UML, Final State is represented by double circle:
stateDiagram-v2
InitialState --> [*] : Finish
Equivalent Stateflows notation of States:
Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState("InitialState", b => b
.AddTransition<Finish>("final")
)
.AddFinalState("final")If there is just one Final State in State Machine, shortened notation with default name can be used:
Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState("InitialState", b => b
.AddTransition<Finish>(FinalState.Name)
)
.AddFinalState() // no name provided here, default name usedUsing lambda style here means that Final State is referred to by string name.
public class InitialState : IState
{ }Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState<InitialState>(b => b
.AddTransition<Finish, FinalState>()
)
.AddFinalState()Using typed style here means that Final State is represented by a class, in the example predefined
FinalStateclass is used.
FinalState class can be used as a target for typed style Transitions if State Machine contains just one Final State. If there are more Final States, there is an important concern of State identity to be considered.
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