Using the Windows Workflow SynchronizationScopeActivity with the ParallelActivity

I my previous post on the ParallelActivity I mentioned that the execution of activities contained in the child SequenceActivity(s) is not what you might expect.  The workflow engine switches among the threads which could lead to undesired results if you need to insure that one sequence completes before another begins.

Fortunately the fix is very simple.  All you need to do is to add a SynchronizationScopeActivity to your workflow.  This will insure that everything in that scope will happen as a unit.  I've made a couple of minor changes to my ParallelWorkflow to take advantage of this.  You can see the finished sample here.

image