I use stateless to implement state machine logic in our application. We have a state AcceptedFilethat has another internal (sub). The problem is that I don’t know how to specify the initial internal state in my code, so that when the machine AccptedFilegoes into state , it will automatically go back to its original internal state. Here is what I did with simulate this behavior:
machine.Configure(State.AcceptedFile)
.OnEntry(() => machine.Fire(Trigger.MakeReadyForAdvertising))
.Permit(Trigger.MakeReadyForAdvertising,State.ReadyForAdvertising)
here ReadyForAdvertisingis an internal state AcceptedFile. This works great in most scenarios, but whenever I set the initial state of my state machine to AcceptedFileas follows:
var statemachine=new StateMachine<State,Trigger>(State.AcceptedFile)
...
An automatic transition will not occur, so the machine will be in the AcceptedFile state instead ReadyForAdvertising.
Is there a better way to implement this behavior?
source
share