Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues Running StateMachine #41

Closed
luckielordie opened this issue Apr 14, 2019 · 3 comments
Closed

Issues Running StateMachine #41

luckielordie opened this issue Apr 14, 2019 · 3 comments

Comments

@luckielordie
Copy link

I'm having trouble getting the statemachine to transition.

Am I allowed to fire and event from inside an OnEntry function?
When I've called Start on the statemachine do I need to do a while loop to keep the state machine open?
Do you have a working code example for the tutorial on the site? It would be nice to see a full code structure just to see how you expect an IStateMachine to be interacted with.

@ursenzler
Copy link
Member

Take a look at this test (https://github.com/appccelerate/statemachine/blob/master/source/Appccelerate.StateMachine.Specs/Async/Transitions.cs), it shows how the state machine can be used.

And here (http://www.appccelerate.com/statemachinesample.html) you find some explanations.

You can fire an event inside an OnEntry function, but I guess there would be a better state machine design that models the states better. A state that is left immediately is normally not a state, but part of a transition.

There are two flavours of the state machine: passive and active. The passive state machine executes a transition whenever you call Fire on it and will block the caller until it is finished. The active state machine has an internal thread that will execute the transition, the caller is not blocked.
So you simply need to hold the instance of the state machine and make Firecalls (don't forget to first Initialize and then Start).

Let me know if this helps, otherwise I'll add a sample project to the solution.

@luckielordie
Copy link
Author

Thanks for the swift reply! I'll have some time later on today to have a look at this.

I appreciate this is probably my naivety of the language, I'm seeing a lot of 'await' In the code sample that I have yet to learn fully. Thanks for your patience.

@ursenzler
Copy link
Member

ursenzler commented Apr 15, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants