.NET Framework Class Library
Activity Class

Represents the fundamental building block of workflows. Activity is the base class for all activities.

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

Visual Basic (Declaration)
<RuntimeNamePropertyAttribute("Name")> _
<ActivityCodeGeneratorAttribute(GetType(ActivityCodeGenerator))> _
<ActivityValidatorAttribute(GetType(ActivityValidator))> _
<ToolboxBitmapAttribute(GetType(Activity), "Design.Resources.Activity.png")> _
Public Class Activity _
    Inherits DependencyObject
Visual Basic (Usage)
Dim instance As Activity
C#
[RuntimeNamePropertyAttribute("Name")]
[ActivityCodeGeneratorAttribute(typeof(ActivityCodeGenerator))]
[ActivityValidatorAttribute(typeof(ActivityValidator))]
[ToolboxBitmapAttribute(typeof(Activity), "Design.Resources.Activity.png")]
public class Activity : DependencyObject
Visual C++
[RuntimeNamePropertyAttribute(L"Name")]
[ActivityCodeGeneratorAttribute(typeof(ActivityCodeGenerator))]
[ActivityValidatorAttribute(typeof(ActivityValidator))]
[ToolboxBitmapAttribute(typeof(Activity), L"Design.Resources.Activity.png")]
public ref class Activity : public DependencyObject
JScript
public class Activity extends DependencyObject
Remarks

An Activity is the fundamental building block of workflows. An Activity defines a set of properties and events, such as any class, along with execution logic that defines the activity's run-time behavior. A set of additional components can be associated with an Activity. These include, but are not limited to a validator, a code generator, custom serializers, and a designer.

All activities share a common set of properties defined on the Activity base class. Each Activity can declare its own additional properties according to its requirements by extending this class. Because Activity derives from DependencyObject, properties can be defined as standard CLR properties and as dependency properties.

The execution logic of an Activity fulfills a contract that exists between any Activity and the workflow runtime. You must document the execution logic of any Activity in a functional sense, so that a workflow developer who uses the Activity knows how it behaves. The execution logic itself is hidden from the workflow developer who includes the activity in a workflow, because the execution logic is part of a contract that exists strictly between the workflow runtime and the Activity.

Examples

This example defines an activity whose purpose is to send an email. The activity defines one property, Subject, that uses a dependency property in its implementation. Other properties can be defined in a similar way. The Execute method is overridden to provide the logic for sending the email. For a complete example, see the Send E-mail Activity Sample.

C#
public class SendEmail : Activity
{
    public static readonly DependencyProperty SubjectProperty =
        DependencyProperty.Register("Subject", typeof(string), typeof(SendEmail));

    public string Subject
    {
        get { return base.GetValue(SubjectProperty) as string; }
        set { base.SetValue(SubjectProperty, value); }
    }

    // Define other properties...

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
        // Logic to send the e-mail goes here...
        return ActivityExecutionStatus.Closed;
    }
}
Inheritance Hierarchy

System..::.Object
  System.Workflow.ComponentModel..::.DependencyObject
    System.Workflow.ComponentModel..::.Activity
      System.Workflow.Activities..::.CallExternalMethodActivity
      System.Workflow.Activities..::.CodeActivity
      System.Workflow.Activities..::.DelayActivity
      System.Workflow.Activities..::.HandleExternalEventActivity
      System.Workflow.Activities..::.InvokeWebServiceActivity
      System.Workflow.Activities..::.InvokeWorkflowActivity
      System.Workflow.Activities..::.PolicyActivity
      System.Workflow.Activities..::.SendActivity
      System.Workflow.Activities..::.SetStateActivity
      System.Workflow.Activities..::.WebServiceFaultActivity
      System.Workflow.Activities..::.WebServiceInputActivity
      System.Workflow.Activities..::.WebServiceOutputActivity
      System.Workflow.ComponentModel..::.CompensateActivity
      System.Workflow.ComponentModel..::.CompositeActivity
      System.Workflow.ComponentModel..::.SuspendActivity
      System.Workflow.ComponentModel..::.TerminateActivity
      System.Workflow.ComponentModel..::.ThrowActivity
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

Tags :


Community Content

christophercarter
System.Workflow.ComponentModel
  public
  class SendEmail : Activity
{
publicstatic readonly DependencyProperty SubjectProperty =
DependencyProperty.Register("Subject", typeof(string), typeof(SendEmail));

publicstring Subject
{
get { returnbase.GetValue(SubjectProperty) as string; }
set { base.SetValue(SubjectProperty, value); }
}

// Define other properties...

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
// Logic to send the e-mail goes here...
return ActivityExecutionStatus.Closed;
}
}
Tags :

Page view tracker