CompositeActivity Class
Derivative of Activity that is the base class for all activities that contain other activities. A CompositeActivity is responsible for managing the execution of its child activities.
Assembly: System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)
A CompositeActivity manages the execution of its child activities using ActivityExecutionContext class methods and events defined on the Activity class. For example, a child activity is scheduled for execution using the ExecuteActivity of ActivityExecutionContext. A CompositeActivity activity can be notified when a child activity completes its execution by subscribing to the Closed event defined on Activity.
The workflow runtime enforces certain constraints on CompositeActivity execution, the most fundamental of which is that a CompositeActivity activity cannot move to the Closed state if any child activities are still in a Executing, Canceling, Compensating, or Faulting, state.
This example shows a basic CompositeActivity that executes its first child activity for execution. When the child activity moves to the Closed state, the composite activity is notified and then completes its execution.
public class HasOneChildActivity : CompositeActivity { protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { Activity child = this.EnabledActivities[0]; child.Closed += this.ChildClosed; executionContext.ExecuteActivity(child); return ActivityExecutionStatus.Executing; } void ChildClosed(object sender, ActivityExecutionStatusChangedEventArgs e) { e.Activity.Closed -= this.ChildClosed; ActivityExecutionContext executionContext = sender as ActivityExecutionContext; executionContext.CloseActivity(); } }
System.Workflow.ComponentModel.DependencyObject
System.Workflow.ComponentModel.Activity
System.Workflow.ComponentModel.CompositeActivity
System.Workflow.Activities.ConditionedActivityGroup
System.Workflow.Activities.EventHandlersActivity
System.Workflow.Activities.EventHandlingScopeActivity
System.Workflow.Activities.IfElseActivity
System.Workflow.Activities.ListenActivity
System.Workflow.Activities.ParallelActivity
System.Workflow.Activities.ReplicatorActivity
System.Workflow.Activities.SequenceActivity
System.Workflow.Activities.StateActivity
System.Workflow.Activities.WhileActivity
System.Workflow.ComponentModel.CancellationHandlerActivity
System.Workflow.ComponentModel.CompensatableTransactionScopeActivity
System.Workflow.ComponentModel.CompensationHandlerActivity
System.Workflow.ComponentModel.FaultHandlerActivity
System.Workflow.ComponentModel.FaultHandlersActivity
System.Workflow.ComponentModel.SynchronizationScopeActivity
System.Workflow.ComponentModel.TransactionScopeActivity
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.