CompositeActivity Class
This page is specific to:.NET Framework Version:3.03.54.0
.NET Framework Class Library
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.

Namespace:  System.Workflow.ComponentModel
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)
Syntax

'Usage

Dim instance As CompositeActivity

'Declaration

<ActivityValidatorAttribute(GetType(CompositeActivityValidator))> _
<ContentPropertyAttribute("Activities")> _
<ActivityCodeGeneratorAttribute(GetType(CompositeActivityCodeGenerator))> _
Public Class CompositeActivity _
    Inherits Activity
Remarks

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.

Examples

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();
    }
}
Inheritance Hierarchy

System..::.Object
  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
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View