views:

24

answers:

2

This is the scenario:

I have a State Machine Workflow using ManualWorkflowScheduler. Say there are 2 states: State1 and State2. State1 contains an EventDrivenActivity1 that has a SetStateActivity1 moving the workflow from State1 to State2. State1 also has a StateFinalizationActivity1.

So my question is:

When an event is raised and SetStateActivity1 executes and changes the state of the workflow to State2, is StateFinalizationActivity1 executed on the same thread (as part of the call) as the method that raised the event causing state change (meaning - does the caller method have to wait until both sequences of EventDrivenActivity1 and StateFinalizationActivity1 executes, or it will return after EventDrivenActivity1 is executed and StateFinalizationActivity1 is going to be executed after the return)?

+1  A: 

When using the ManualWorkflowScheduler everything that can be executed will on the current thread. So the workflow will continue and run all the way until its is in the next state and idle.

Maurice
+1  A: 

The use of the word "Finalization" I guess might cause some to think of the CLR finalization which would run on a different thread. However this is very different concept.

When a SetStateActivity is hit the following sequence happens:-

  • other currently executing activities in the current state will run any activities in their Cancel handling.
  • the activities in the StateFinalization will execute
  • the state is transitioned to the new state
  • any activities in the new states Initialization Activity will run
  • the Event activity in the states body is entered.

All of the above operates in sequence on the current thread.

AnthonyWJones