Tuesday, February 26, 2008

Nested State Activities in Windows Workflow

By pure accident today I stumbled upon Nested State Activities, and of course my curiosity got the best of me in finding out what exactly these things are, how they worked, and who had done anything with it.

A quick Google search for Nested State Activity didn't turn up much, except an article on MSDN stating that they were beyond the scope of this article. Still, good article on state machines, you can find it here.

Searching a little further, I found an article that somewhat covered it although they didn't use WWF, instead their own state machine toolkit. Also a good read and can be found here.

However I still haven't found much on these things in WWF... So, I decided to play a little. Why not right?


First, lets just look at what a nested state looks like compared to the other in the designer.


Given of course this is a simplistic example at first, so lets explore it a little more. The first question that I asked was "What would I ever need this for?" And to tell you the truth, I don't have a for sure answer for that.

What I have seen so far is that if a state houses other state (in our example above stateActivity1 containing stateActivity2 and stateActivity3) you cannot set that state from another SetState activity. An example of this is from the BuildPublished State I can set the next state to stateActivity2 and stateActivity3 or itself for that matter. however, I cannot set the state to stateActivity1.

Something intereting however, stateActivity1 can have events handling scopes associated with it. So it appears the event can respond when the the current state is within one of the sub states.

I haven't found a great use of this yet, however the ability to have substates does add a new level of capability that I never realized. I guess an example of its use may be a help desk application in which case when an issue is resolved you may have substates such as post-mortum review, develop action plan, and something else.

I may explore this more later if I see a need, but thought it was cool nonetheless.

1 comment:

  1. use of hierarchical state machines explained here : http://www.odetocode.com/Articles/460.aspx

    ReplyDelete