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

Stop/abort passive state machine #57

Open
dmumladze opened this issue Oct 30, 2019 · 3 comments
Open

Stop/abort passive state machine #57

dmumladze opened this issue Oct 30, 2019 · 3 comments

Comments

@dmumladze
Copy link

dmumladze commented Oct 30, 2019

Question: Is there a way to abort the state machine to prevent any further transitions? I used the Stop() method, but it doesn't stop it. I understand it may not be recommended to do so, but there's no need to keep transitioning if there's an transient exceptions and whatnot... Could you please suggest a recommended way to deal with such cases?

@ursenzler
Copy link
Member

Can you proved more information why stop didn't work? Was it an active or passive, an async or synchronous state machine? The behaviour of Stops is different for the 4 kinds of machines.

For exceptions, you can introduce a global transition (pack all states into a superstate that has this transition) for exceptions and fire an event representing this scenario with FirePriority so that it gets to the head of the queue of events to process.

@dmumladze
Copy link
Author

It's AsyncPassiveStateMachine. As it transitions though states, I see TransitionExceptionThrown event triggering, but it keep going without stopping. I tried to call Stop in TransitionExceptionThrown handler, but state machine does not stop.

@ursenzler
Copy link
Member

Yes, the passive state machines continue executing the current "stack" of events and will only stop once they are all executed.
The state machine will pass exceptions to your code (via the event handler) and continue running. For me, that is the best the state machine can do. If you want to state machine to throw an exception, don0t register a listener for TransitionExceptionThrown. The state machine checks whether there is a listener.

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