Skip to content
C# based state machine
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status License

A simple C# based State Machine that can be configured via State Transitions based on an idea by Juliet "Simple state machine example in C#?"

You can download this package via NuGet with Install-Package biz.dfch.CS.StateMachine.


The project contains an extendable StateMachine that defines a few simple states and two conditions ("Continue", "Cancel") that can be used to advance (transition) through that state machine.

When instatiating the StateMachine with the default constructor the following states, conditions and transitions will be set up per default


  • Running
  • InternalErrorState
  • Completed
  • Cancelled
  • Disposed


  • Continue
  • Cancel


Source state Condition Target state
InitialState Continue Running
InitialState Cancel InternalErrorState
Running Continue Completed
Running Cancel Cancelled
Completed Continue Disposed
Completed Cancel InternalErrorState
Cancelled Continue Disposed
Cancelled Cancel InternalErrorState
InternalErrorState Continue Disposed

Basic functionalities

  1. The Continue condition makes a transition from an arbitrary state to the next state as the "good case"
  2. The Cancel condition makes a transition from an arbitrary state to the next state as the "bad case"
  3. Furthermore there is the GetNext method to transit to the next state based on a given condition.

There are as well methods for exporting and importing the configuration along with the states:

Release Notes

1.2.0 20150926

  • adjust namespace
  • States and Conditions can now be retrieved by consumer
  • added code contracts pre-conditions
  • enabled CodeContracts assemlby

TeamCity Logo

Built and released with TeamCity

You can’t perform that action at this time.