How SharePoint Foundation Processes Workflow Activities

Applies to: SharePoint Foundation 2010

It is worth understanding how Microsoft SharePoint Foundation processes SharePoint Foundation-specific workflow activities in a running workflow instance.

SharePoint Foundation runs the workflow until it reaches a point where it cannot proceed because it is waiting for some event to occur: for example, a user must designate a task as completed. Only at this "commit point" does SharePoint Foundation commit the changes made in the previous SharePoint Foundation-specific workflow activities. Those changes are batched into a single SQL transaction. This approach has two major advantages:

  • Batching the changes into a single SQL transaction is less performance intensive than committing each change as it occurs as a separate transaction.

  • If any of the changes fail when committed, SharePoint Foundation rolls all the changes back to the previous "commit point." This greatly decreases the amount of work developers have to do when creating exception handlers and compensation handlers for Windows SharePoint Services-specific workflow activities.

When the event for which the workflow is waiting occurs, SharePoint Foundation resumes running the workflow. Again, the workflow runs until another event is reached or the workflow ends, at which point SharePoint Foundation commits any changes made by SharePoint Foundation-specific workflow activities subsequent to the last commit point. This continues until the workflow reaches its conclusion or is stopped by the user.

This approach can affect workflows in which you have interspersed Code activities with SharePoint Foundation-specific workflow activities. Although the write operations for the SharePoint Foundation-specific workflow activities are batched and not committed until a commit point is reached, any write operations you include in Code activities are committed as they occur. Also, Code activities do not have the implicit rollback functionality of SharePoint Foundation-specific workflow activities; if you want error handling for them, you need to write exception and compensation handlers for those activities.

See Also

Concepts

Workflow Activities for SharePoint Foundation

Correlation Tokens in Workflows

Workflow Initiation in SharePoint Foundation