Activity Class
Represents the fundamental building block of workflows. Activity is the base class for all activities.
Assembly: System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)
'Declaration <RuntimeNamePropertyAttribute("Name")> _ <ActivityCodeGeneratorAttribute(GetType(ActivityCodeGenerator))> _ <ActivityValidatorAttribute(GetType(ActivityValidator))> _ <ToolboxBitmapAttribute(GetType(Activity), "Design.Resources.Activity.png")> _ Public Class Activity _ Inherits DependencyObject 'Usage Dim instance As Activity
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.
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; } }
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
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.