Skip to content

How to implement a pause state and exit from the paused state in a state machine? #537

Answered by crozone
vkensou asked this question in Q&A
Discussion options

You must be logged in to vote

Consider making "In Progress" a superstate that encapsulates "Paused" and "Running". Then you can have another "Stopped" state as the initial state.

The "Start" trigger would transition "Stopped" -> "In Progress". The initial state for "In Progress" would be "Running".

The "Pause" trigger would transition "Running" -> "Paused".

The "Resume" trigger would transition "Paused" -> "Running".

The "End" trigger would transition "In Progress" -> "Stopped". Resource cleanup occurs on entry to "Stopped".

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vkensou
Comment options

Answer selected by vkensou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants