If you are looking for a .Net based high performance state machine I would recommend Stateless. Here is an excerpt from the project site:
Most standard state machine constructs are supported:
- Generic support for states and
triggers of any .NET type (numbers,
strings, enums, etc.)
- Hierarchical states Entry/exit
events for states
- Guard clauses to support conditional
transitions
- Introspection
Some useful extensions are also provided:
- Ability to store state externally
(for example, in a property tracked
by Linq to SQL)
- Parameterised triggers
- Reentrant states
Configuration is as follows:
var phoneCall = new StateMachine<State, Trigger>(State.OffHook);
phoneCall.Configure(State.OffHook)
.Permit(Trigger.CallDialed, State.Ringing);
phoneCall.Configure(State.Ringing)
.Permit(Trigger.HungUp, State.OffHook)
.Permit(Trigger.CallConnected, State.Connected);
phoneCall.Configure(State.Connected)
.OnEntry(() => StartCallTimer())
.OnExit(() => StopCallTimer())
.Permit(Trigger.LeftMessage, State.OffHook)
.Permit(Trigger.HungUp, State.OffHook)
.Permit(Trigger.PlacedOnHold, State.OnHold);
// ...
phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);
And the nice thing is that since it implements Generics, you can use int or string to represent the states and triggers, allowing you to integrate very easily with your database or ORM. The beauty is that there is no additional runtime host that you have to worry about, just load the state machine with the current state from an object or a record and you are good to go.