It is quite easy to make.
You start at first with designing the states in a tool like this:
It will help you visualize what you want to do. Afterwards you create a main sub named StateSelector. It will be like this:
Sub StateSelector(u as byte)
Select Case u
Case 1
CallSubPlus("State1", 10, 0)
Case 2
CallSubPlus("State2", 10, 0)
Case 3
CallSubPlus("State3", 10, 0)
' .
' .
' .
' .
' .
End Select
End Sub
Each Sub Executes Code based on what you want it to do and according to the available ways out from it in relation to values you CallSubPlus("StateSelector", 10, x) where x is the number of the state you want to go.
If you make a call to an external service with httpUtils you continue to the code you want from JobDone again with CallSubPlus("StateSelector", 10, y).
CallSubPlus is used so that you do not end up going from state to state in an endless stack. With CallSubPlus the Sub is called after T milliseconds and the state machine is able to exit the calling sub before the new sub is called.