Click here to Skip to main content
15,916,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm wanting to use a state engine within my application, I've done a lot of googling but the only how-to's available online show state engines running as a console application.

What I looking at doing is :

The windows form ( on button press ) would start the state machine, and at each state the machine would then trigger a function within my form, the function would then execute and trigger the transition to the next state.

I also want to design the engine via Windows Workflow Editor

I must say, I've no experience with state machines so dont even know if what I'm suggesting is indeed possible.

Any advice is appreciated.

What I have tried:

Googled several articles but without any success
Updated 4-May-24 23:00pm
Ralf Meier 5-May-24 6:14am    
Please explain a little bit better what you are trying ... perhaps with some examples, What are the condition(s) to go to the next step ?
Ziggy_C 7-May-24 15:53pm    
I'm trying to use a 'state machine' within my form, I want to use it as a 'procedure flow', essentially each state will tell my application which method to run, pausing the flow and wait until its complete, once complete, the result is then sent back to the flow as a trigger ie true / false

For ease I wish to use Workflow editor within VS, but all the examples I've seen only show a console application.

Is this possible ?
Ralf Meier 10-May-24 14:30pm    
Sorry for my late response - it could have been earlier if you used the REPLY-widget insteat of writing a new comment.
Basicly @Grame_Grant has posted a possible Solution to do that.
You should use the SELECT CASE Statement with for example an Integer-Variable.
Now each Step of yor Statemachine is a new CASE of this with a new Value of that Integer.
After doing a step you should increase that Variable for the next step. Inside this next step you wait for the result to increase the Variable again ... and so on ...
Is that clear for you or should I create an example ?
Ziggy_C 20-May-24 10:34am    
Hi Ralf, Apologies for my delay in replying, when you have a minute, could you please provide an example, many thanks

1 solution

This is called the State Design Pattern.

A quick google search: state design pattern vb - Google Search[^]. There are many examples to choose from, like: State Machine - State Pattern vs. Classic Approach - Code Project[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900