Windows Workflow Foundation: Parallel Activities Aren't Exactly Parallel
It came as a bit of a surprise to me that Parallel activities in Windows Workflow Foundation are not in fact asynchronous. Since investigating I've seen that several people have mentioned this fact but I thought a more descriptive example might be in order.
Consider the following sequential workflow hosted in a console application. In it I have one parallel activity with three branches. Each branch has two code activities. There is a final code activity at the end of the workflow.
In each code activity I merely echo a number matching the Code activity number. So activity Code1 displays "1" and Code2 displays "2". Note that I have numbered them across the branches. Code 7 displays the word "Done". Now, if parallel activities executed their branches asynchronously you'd expect that I would see the results in a seemingly random set of "1/4", "2/5", and "3/6". Instead what you get is this:
The Scheduler inside the WF (Formerly known as WWF) executes the first activity of each branch before moving to the second as well as moving through the branches in order. Execution takes place on the same thread from the CLR Threadpool for each activity.
Tomorrow Soon, I'll show one example of how to make each of the branches execute asynchronously.
Here's a link to the sample workflow project.