Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Activity Class

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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)
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

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.

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;
    }
}
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
System.Workflow.ComponentModel      christophercarter   |   Edit   |   Show History
  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 What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker