XStateNet
.NET implementation of the finite state machine framework. Powerful and asynchronous framework to build and run finite state machines in .NET.
Purpose of the Library
In many cases when you code the device control module with C# or user behavior flow logic (purchase transactions, elevator control, even a coffee machine demo) you are falling into the case of coding a state machine.
Any system is a composition of states and transitions, or can be at least represented as a states chart. Remember UML state diagram.
This library provides a set of classes and methods to declare, build and run asynchronous finite state machines in C#.
The library was built after two years of experience working with different state machine implementations for one of the projects I had related to vending machines and user behaviours. Every method this framework provides was used in practical life, not only in academic research.
Main Features
- Declarative state machine building and running in asynchronous mode, with awaiting or without (non blocking the main thread);
- States can execute delegate with callback to generate multiple events and have various state switch transitions, as well as asynchronous actions to switch state on action done or error; Each service can execute also another state machine and move to another state on machine done or error;
- Side effects for each state: actions on state enter, on state exit. Activities - long running awaitable and task with cleanup method that runs while machine is in the certain state but that action can't affect state machine.
- Additional service types and modes for state: transient state, timeout service, final state;