Using the CompensatableSequenceActivity Activity

The CompensatableSequenceActivity activity is a compensatable version of the SequenceActivity activity which implements the ICompensatableActivity interface. CompensatableSequenceActivity implements the ICompensatableActivity interface. By implementing this interface, the CompensatableSequenceActivity can have a CompensationHandlerActivity as a child. This activity will be executed in the event that the CompensatableSequenceActivity is ever compensated.

Compensation occurs only for successfully completed activities that implement ICompensatableActivity. Compensation can either be implicit as a result of an exception occurring in a parent activity, or explicit through the use of the CompensateActivity activity.

The CompensatableSequenceActivity is appropriate to use when there is non-transactional work to be done which, due to some error condition, may need to be undone later. For example, if a workflow has sent an e-mail message and, due to a later error, a retraction e-mail must be sent, this can be accomplished by placing the activity that sends the first e-mail into the CompensatableSequenceActivity activity, and the activity that sends the retraction e-mail into the corresponding CompensationHandlerActivity. The runtime will thus only run the compensation logic if the first CompensatableSequenceActivity completed successfully (that is, if the first e-mail was sent).

For information about the behavior of a SequenceActivity activity, see Using the SequenceActivity Activity.

For information about compensation, see Using the CompensateActivity Activity and Using the CompensationHandlerActivity Activity.

For a code sample that demonstrates how to use compensation, see Compensation Sample.

See Also




Using the SequenceActivity Activity
Using Compensation in Workflows
Using the CompensateActivity Activity
Using the CompensationHandlerActivity Activity
Using the CompensatableTransactionScopeActivity Activity
Compensation Overview

Other Resources

Compensation Sample
Windows Workflow Foundation Activities