Datasheet

Chapter 1: Work ow Programming Principles
6
One of the base classes from which you can inherit your leaf activity is the standard Activity base class,
which is discussed thoroughly in this section. Every activity in Windows Workflow Foundation inherits
from the Activity base class directly or indirectly. Listing 1 - 1 presents some of the methods, properties,
and events of this base class.
Listing 1 - 1: The Activity base class
public class Activity : DependencyObject
{
// Events
public event EventHandler < ActivityExecutionStatusChangedEventArgs >
Canceling;
public event EventHandler < ActivityExecutionStatusChangedEventArgs >
Closed;
public event EventHandler < ActivityExecutionStatusChangedEventArgs >
Compensating;
public event EventHandler < ActivityExecutionStatusChangedEventArgs >
Executing;
public event EventHandler < ActivityExecutionStatusChangedEventArgs >
Faulting;
// Methods
protected internal virtual ActivityExecutionStatus
Cancel(ActivityExecutionContext executionContext);
protected internal virtual ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext);
protected internal virtual ActivityExecutionStatus
HandleFault(ActivityExecutionContext executionContext, Exception exception);
protected internal virtual void Initialize(IServiceProvider provider);
protected internal virtual void Uninitialize(IServiceProvider provider);
// Properties
public string Description { get; set; }
public bool Enabled { get; set; }
public ActivityExecutionResult ExecutionResult { get; }
public ActivityExecutionStatus ExecutionStatus { get; }
public bool IsDynamicActivity { get; }
public string Name { get; set; }
public CompositeActivity Parent { get; }
}
I discuss the members of the Activity base class in the following sections. You need to have a thorough
understanding of these members if you re going to inherit from this base class to implement your
custom activity, because your custom activity must override the appropriate methods of this base class.
Activity Initialization
The Initialize method of an activity is the first method of the activity to execute. An activity overrides
this method to initialize itself. Note that when this method is invoked, an activity has not yet started its
execution because the Execute method of the activity has not yet been invoked. When the Initialize
c01.indd 6c01.indd 6 8/25/08 4:02:53 PM8/25/08 4:02:53 PM