Search

Search:

Namespace:

Search Result
.
Summary
.

http://msdn.microsoft.com/en-us/library/system.workflow.runtime.workflowinstance.applyworkflowchanges.aspx

.

Use the WorkflowChanges to create the changes and the ApplyWorkflowChanges to actually apply the change to the workflow.

.

So what do we actually need to change an executing WorkflowInstance? The class to start with is the WorkflowChanges. This WorkflowChanges object has a property named TransientWorkflow that lets us get to the actual workflow definition. Now we can use this to add the activities we want. In fact we can also change or remove activities as well.

.

WorkflowChanges changes = new WorkflowChanges(this);

.
        ApplyWorkflowChanges(changes);
.

The most important thing to notice is that the ApplyWorkflowChanges is the one that actually changes the running WorkflowInstance. And if the update fails for some reason an WorkflowValidationFailedException is thrown with a property Errors that is a collection of ValidationError objects.

.

Before using the ApplyWorkflowChanges function we can validate the changes. This will catch some, but not all possible, errors so just validating and removing the try/catch is not recommended.

.

http://msdn.microsoft.com/en-us/library/system.workflow.componentmodel.workflowchanges.aspx