Workflow Foundation is “very” single threaded, but…



Workflow Foundation is single threaded (one thread at a time will run your workflow instance, but the workflowRuntime is multithreaded : several workflows can run simultaneously), even when we use the ParallelActivity which coordonates execution
of activities in multiple branches in a round-robin fashion; this doesn’t mean the same thread will always run the workflow instance: indeed, if we use the DelayActivity (or if the workflow wait for another kind of message), the running thread is released and after the delay, another thread can be used to run the workflow.
This is true even in a TransactionScopeActivity !!!
By the way, you need to know that if you use the SqlWorkflowPersistenceService with the flag UnloadOnIdle set  to true, if your workflow becomes idle in the middle of a TransactionScope activity, your workflow WON’T BE PERSISTED. There is a tight coupling between the TransactionScopeActivity (TSCA) and the workflowRuntime which prevents it to be persisted & unloaded; the workflowRuntime also gives a higher priority to the child activities of the TSCA and this has an impact if we have a TSCA in one branch of a ParallelActivity and a Sequence activity in the other branch of the ParallelActivity.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s