EventDrivenActivity 类
定义
注意
The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*
public ref class EventDrivenActivity sealed : System::Workflow::Activities::SequenceActivity
[System.Drawing.ToolboxBitmap(typeof(System.Workflow.Activities.EventDrivenActivity), "Resources.EventDriven.png")]
[System.Workflow.ComponentModel.Compiler.ActivityValidator(typeof(System.Workflow.Activities.EventDrivenValidator))]
public sealed class EventDrivenActivity : System.Workflow.Activities.SequenceActivity
[System.Drawing.ToolboxBitmap(typeof(System.Workflow.Activities.EventDrivenActivity), "Resources.EventDriven.png")]
[System.Workflow.ComponentModel.Compiler.ActivityValidator(typeof(System.Workflow.Activities.EventDrivenValidator))]
[System.Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
public sealed class EventDrivenActivity : System.Workflow.Activities.SequenceActivity
[<System.Drawing.ToolboxBitmap(typeof(System.Workflow.Activities.EventDrivenActivity), "Resources.EventDriven.png")>]
[<System.Workflow.ComponentModel.Compiler.ActivityValidator(typeof(System.Workflow.Activities.EventDrivenValidator))>]
type EventDrivenActivity = class
inherit SequenceActivity
[<System.Drawing.ToolboxBitmap(typeof(System.Workflow.Activities.EventDrivenActivity), "Resources.EventDriven.png")>]
[<System.Workflow.ComponentModel.Compiler.ActivityValidator(typeof(System.Workflow.Activities.EventDrivenValidator))>]
[<System.Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")>]
type EventDrivenActivity = class
inherit SequenceActivity
Public NotInheritable Class EventDrivenActivity
Inherits SequenceActivity
- 继承
- 属性
示例
下面的代码示例演示如何使用 EventDrivenActivity 来执行状态机转换。The following code example shows how to use the EventDrivenActivity to perform state machine transitions. 此代码示例摘自 StateMachineWorkflow.cs 文件中的“SimpleStateMachineWorkflow”SDK 示例。This code example is part of the SimpleStateMachineWorkflow SDK sample from the StateMachineWorkflow.cs file. 有关详细信息,请参阅 简单状态机。For more information, see Simple State Machine.
this.state1Delay = new System.Workflow.Activities.DelayActivity();
Me.state1Delay = New System.Workflow.Activities.DelayActivity
注解
备注
本材料讨论的类型和命名空间已废弃不用。This material discusses types and namespaces that are obsolete. 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型。For more information, see Deprecated Types in Windows Workflow Foundation 4.5.
它是一种用于处理事件的 CompositeActivity;通常可以从宿主中引发,或由运行时在响应延迟计时器过期时引发。It is a CompositeActivity that is used to handle an event; typically it can be raised from the host or by the runtime in response to a delay timer expiring. EventDrivenActivity 继承自 SequenceActivity,因此,它是一个序列,此序列具有一个附加限制(即第一个活动应该为 IEventActivity)。EventDrivenActivity is inherited from SequenceActivity; therefore, it is a sequence that has the additional restriction that the first activity should be an IEventActivity.
EventDrivenActivity 是一种 CompositeActivity,这意味着 EventDrivenActivity 可以包含其他活动。The EventDrivenActivity is a CompositeActivity, which means the EventDrivenActivity can contain other activities. EventDrivenActivity 类似于 SequenceActivity 活动,但具有一些附加特性。The EventDrivenActivity is similar to the SequenceActivity activity, with some additional characteristics.
EventDrivenActivity 必须具有父级,该父级可以是 ListenActivity、StateActivity 或 StateMachineWorkflowActivity。An EventDrivenActivity must have a parent that is either a ListenActivity, StateActivity, or StateMachineWorkflowActivity.
EventDrivenActivity 活动的第一个子级必须是继承自 IEventActivity 的活动。The first child of an EventDrivenActivity activity must be an activity that inherits from IEventActivity. 所有后续子级可以是任意类型的活动。All subsequent children can be activities of any type. IEventActivity 会阻止和等待某些事件的延迟发生,比如计时器的启动或消息的到达。The IEventActivity blocks and waits for the pending occurrence of some events, such as starting a timer or the arrival of a message. 当事件发生时,IEventActivity 会结束运行,之后执行所有的后续活动。When the event occurs, the IEventActivity finishes running and then all subsequent activities are executed.
如果 StateMachineWorkflowActivity 包含 EventDrivenActivity,则 EventDrivenActivity 具有某些限制:When the StateMachineWorkflowActivity contains an EventDrivenActivity, the EventDrivenActivity has some restrictions:
EventDrivenActivity 可能包含一个,并且只有一个 IEventActivity 类型的活动。The EventDrivenActivity may contain one, and only one, activity of type IEventActivity.
HandleExternalEventActivity 必须是第一个子活动。The HandleExternalEventActivity must be the first child activity. 如果 HandleExternalEventActivity 不是第一个子级,则 EventDrivenActivity 不能位于子活动的事件处理程序中,也不能是 HandleExternalEventActivity 的子级。An HandleExternalEventActivity cannot be in the event handler for a child activity and cannot be a child to the EventDrivenActivity if the HandleExternalEventActivity is not the first child.
只要第一个活动是 HandleExternalEventActivity,事件处理程序就可以包含任何活动。As long as the first activity is the HandleExternalEventActivity, the event handler can contain any activities. 如果 HandleExternalEventActivity 中包含 EventDrivenActivity 以外的活动,则该活动不能具有事件处理程序。If an activity other than HandleExternalEventActivity is contained in EventDrivenActivity, that activity cannot have an event handler.
例如,EventDrivenActivity 中可以使用支持事件处理的活动,但该活动不能对其自身附加事件处理程序。For example, an activity that supports event handling can be used inside the EventDrivenActivity but the activity cannot have event handlers attached to itself.
另一个示例是 EventDrivenActivity 可以包含 ConditionedActivityGroup,但 ConditionedActivityGroup 本身不能包含任何 HandleExternalEventActivity 类。Another example is that the EventDrivenActivity can contain a ConditionedActivityGroup, but the ConditionedActivityGroup itself cannot contain any HandleExternalEventActivity classes.
构造函数
| EventDrivenActivity() |
初始化 EventDrivenActivity 类的新实例。Initializes a new instance of the EventDrivenActivity class. |
| EventDrivenActivity(String) |
使用活动名初始化 EventDrivenActivity 类的新实例。Initializes a new instance of the EventDrivenActivity class using the name of the activity. |
属性
| Activities |
获取表示所有子活动的集合 ActivityCollection 的对象。Gets the object representing the collection, ActivityCollection, of all child activities. (继承自 CompositeActivity) |
| CanModifyActivities |
获取或设置一个值,该值控制是否可以修改 Activities 中的单个活动。Gets or sets a value which controls whether the individual activities within Activities can be modified. (继承自 CompositeActivity) |
| Description |
获取或设置 Activity 的用户定义说明。Gets or sets the user-defined description of the Activity. (继承自 Activity) |
| DesignMode |
获取一个值,该值指示此实例是处于设计模式还是运行时模式。Gets the value that indicates whether this instance is in design or run-time mode. (继承自 DependencyObject) |
| Enabled |
获取或设置一个值,该值指示是否启用此实例以供执行和验证。Gets or sets a value that indicates whether this instance is enabled for execution and validation. (继承自 Activity) |
| EnabledActivities |
获取表示已启用的 Activities 的子集的只读集合。Gets the read-only collection that represents the subset of Activities that are enabled. (继承自 CompositeActivity) |
| EventActivity |
获取驱动更改的事件活动。Gets the event activity that drives the change. |
| ExecutionResult |
获取最后一次尝试运行此实例产生的 ActivityExecutionResult。Gets the ActivityExecutionResult of the last attempt to run this instance. (继承自 Activity) |
| ExecutionStatus |
获取此实例的当前 ActivityExecutionStatus。Gets the current ActivityExecutionStatus of this instance. (继承自 Activity) |
| IsDynamicActivity |
获取有关活动是否在工作流实例的默认 ActivityExecutionContext 中执行的信息。Gets information about whether the activity is executing within the default ActivityExecutionContext of the workflow instance. (继承自 Activity) |
| Name |
获取或设置此实例的名称。Gets or sets the name of this instance. 此名称必须符合工作流项目中使用的编程语言的变量命名规则。This name must conform to the variable naming convention of the programming language that is being used in the Workflow project. (继承自 Activity) |
| Parent |
获取包含此 CompositeActivity 的 Activity。Gets the CompositeActivity that contains this Activity. (继承自 Activity) |
| ParentDependencyObject |
获取 DependencyObject 图中的父 DependencyObject。Gets the parent DependencyObject in the DependencyObject graph. (继承自 DependencyObject) |
| QualifiedName |
获取活动的限定名。Gets the qualified name of the activity. 活动的限定名在工作流实例中始终是唯一的。Qualified activity names are always unique in a workflow instance. (继承自 Activity) |
| Site |
获取或设置对 Site 的 DependencyObject 组件的引用。Gets or sets a reference to the Site component of the DependencyObject. (继承自 DependencyObject) |
| UserData |
获取一个 IDictionary,它将自定义数据与此类实例关联。Gets an IDictionary that associates custom data with this class instance. (继承自 DependencyObject) |
| WorkflowInstanceId |
获取与实例关联的 Guid。Gets the Guid associated with the instance. (继承自 Activity) |
方法
| AddHandler(DependencyProperty, Object) |
为 DependencyObject 的事件添加处理程序。Adds a handler for an event of a DependencyObject. (继承自 DependencyObject) |
| ApplyWorkflowChanges(WorkflowChanges) |
将参数中的 WorkflowChanges 清单应用到此实例。Applies the WorkflowChanges manifest in the parameter to this instance. (继承自 CompositeActivity) |
| Cancel(ActivityExecutionContext) |
取消活动的执行。Cancels the execution of the activity. (继承自 SequenceActivity) |
| Clone() |
创建 Activity 的深层副本。Creates a deep copy of the Activity. (继承自 Activity) |
| Dispose() |
释放由 DependencyObject 占用的所有资源。Releases all the resources used by the DependencyObject. (继承自 DependencyObject) |
| Dispose(Boolean) |
在此实例上调用 Dispose(Boolean),并可以选择在此实例的所有子活动上调用 Dispose()。Calls Dispose(Boolean) on this instance, and optionally calls Dispose() on all child activities of this instance. (继承自 CompositeActivity) |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| Execute(ActivityExecutionContext) |
执行活动。Executes the activity. (继承自 SequenceActivity) |
| GetActivityByName(String) |
返回 Activity 的实例,其名称由此实例的根活动下(即在工作流中)运行的所有活动的集请求。Returns the instance of the Activity whose name is requested from the set of all activities running under the root activity of this instance, which is within the workflow. (继承自 Activity) |
| GetActivityByName(String, Boolean) |
返回 Activity 的实例,其名称被此实例的根 Activity 下的所有活动的集(如果第二个参数为 |
| GetBinding(DependencyProperty) |
提供对与特定 ActivityBind 关联的 DependencyProperty 的访问。Provides access to the ActivityBind associated with the specific DependencyProperty. (继承自 DependencyObject) |
| GetBoundValue(ActivityBind, Type) |
检索作为 Object 的主题的 ActivityBind。Retrieves the Object that is the subject of an ActivityBind. (继承自 DependencyObject) |
| GetDynamicActivities(Activity) |
返回包含指定活动的所有当前正在执行的实例的数组。Returns an array that contains all of the currently executing instances of the specified activity. (继承自 CompositeActivity) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetInvocationList<T>(DependencyProperty) |
获取一个数组,其中包含指定的 DependencyProperty 的委托。Gets an array that contains the delegates for the specified DependencyProperty. (继承自 DependencyObject) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| GetValue(DependencyProperty) |
提供对指定的 DependencyProperty 的值的访问。Provides access to the value of the designated DependencyProperty. (继承自 DependencyObject) |
| GetValueBase(DependencyProperty) |
提供对 DependencyProperty 的绑定对象的访问,并跳过 GetValue(DependencyProperty) 重写。Provides access to the bound object of a DependencyProperty and bypasses the GetValue(DependencyProperty) override. (继承自 DependencyObject) |
| HandleFault(ActivityExecutionContext, Exception) |
此实例的执行上下文中引发了异常时调用。Called when an exception is raised within the context of the execution of this instance. (继承自 SequenceActivity) |
| Initialize(IServiceProvider) |
初始化此实例的所有适当的子活动和指定的 IServiceProvider。Initializes all appropriate child activities of this instance and the specified IServiceProvider. (继承自 CompositeActivity) |
| InitializeProperties() |
在派生类中重写时,对依赖属性执行初始化。Performs initialization on dependency properties when overridden in a derived class. (继承自 DependencyObject) |
| Invoke<T>(EventHandler<T>, T) |
订阅 EventHandler 并调用该委托。Subscribes an EventHandler and invokes that delegate. (继承自 Activity) |
| Invoke<T>(IActivityEventListener<T>, T) |
订阅 IActivityEventListener<T> 并调用该委托。Subscribes an IActivityEventListener<T> and invokes that delegate. (继承自 Activity) |
| IsBindingSet(DependencyProperty) |
指示 DependencyProperty 的值是否设置为绑定。Indicates whether the value of a DependencyProperty is set as a binding. 请参阅 SetBinding(DependencyProperty, ActivityBind)。See SetBinding(DependencyProperty, ActivityBind). (继承自 DependencyObject) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| MetaEquals(DependencyObject) |
确定此 |
| OnActivityChangeAdd(ActivityExecutionContext, Activity) |
在添加活动时调用。Calls when an activity is added. (继承自 CompositeActivity) |
| OnActivityChangeRemove(ActivityExecutionContext, Activity) |
移除活动时调用。Called when an activity is removed. (继承自 SequenceActivity) |
| OnActivityExecutionContextLoad(IServiceProvider) |
每次加载此活动的 ActivityExecutionContext 时由工作流运行时引擎调用。Called by the workflow runtime engine every time the ActivityExecutionContext for this activity is loaded. (继承自 CompositeActivity) |
| OnActivityExecutionContextUnload(IServiceProvider) |
每次卸载此活动的 ActivityExecutionContext 时由工作流运行时引擎调用。Called by the workflow runtime engine every time the ActivityExecutionContext for this activity is unloaded. (继承自 CompositeActivity) |
| OnClosed(IServiceProvider) |
作为活动向 Closed 状态转换的一部分,由工作流运行时调用。Called by the workflow runtime as part of the activity's transition to the closed state. (继承自 Activity) |
| OnListChanged(ActivityCollectionChangeEventArgs) |
当 Activities 属性发生更改时,执行附加处理。Performs additional processing when the Activities property changes. (继承自 CompositeActivity) |
| OnListChanging(ActivityCollectionChangeEventArgs) |
在对基础 Activities 进行更改之前发生的事件。Event that occurs before a change being made to the underlying Activities. (继承自 CompositeActivity) |
| OnSequenceComplete(ActivityExecutionContext) |
在派生类中重写时,确定活动执行完毕后 SequenceActivity 需要执行的操作。When overridden in a derived class, determines the action taken by the SequenceActivity when the activity has completed execution. (继承自 SequenceActivity) |
| OnWorkflowChangesCompleted(ActivityExecutionContext) |
对此实例的集合 Activities 进行更改之后调用。Called after changes have been made to the collection Activities of this instance. (继承自 SequenceActivity) |
| RaiseEvent(DependencyProperty, Object, EventArgs) |
引发与指定依赖属性关联的 Event。Raises an Event associated with the specified dependency property. (继承自 Activity) |
| RaiseGenericEvent<T>(DependencyProperty, Object, T) |
引发与引用的 DependencyProperty 关联的事件。Raises the event associated with the referenced DependencyProperty. (继承自 Activity) |
| RegisterForStatusChange(DependencyProperty, IActivityEventListener<ActivityExecutionStatusChangedEventArgs>) |
为状态更改事件注册指定的 DependencyProperty。Registers the specified DependencyProperty for the status change event. (继承自 Activity) |
| RemoveHandler(DependencyProperty, Object) |
从关联的 EventHandler 中移除 DependencyProperty。Removes an EventHandler from an associated DependencyProperty. (继承自 DependencyObject) |
| RemoveProperty(DependencyProperty) |
从 DependencyProperty 中移除 DependencyObject。Removes a DependencyProperty from the DependencyObject. (继承自 DependencyObject) |
| Save(Stream) |
将 Activity 写入到 Stream 以便进行保留。Writes the Activity to a Stream for persistence. (继承自 Activity) |
| Save(Stream, IFormatter) |
使用为序列化提供的自定义 Activity 将 Stream 写入到 IFormatter,以便进行保留。Writes the Activity to a Stream for persistence using the custom IFormatter provided for serialization. (继承自 Activity) |
| SetBinding(DependencyProperty, ActivityBind) |
为指定的 ActivityBind 设置 DependencyProperty。Sets the ActivityBind for the specified DependencyProperty. (继承自 DependencyObject) |
| SetBoundValue(ActivityBind, Object) |
设置目标 ActivityBind 的值。Sets the value of the target ActivityBind. (继承自 DependencyObject) |
| SetReadOnlyPropertyValue(DependencyProperty, Object) |
设置只读的 DependencyProperty 值。Sets the value of a DependencyProperty, which is read-only. (继承自 DependencyObject) |
| SetValue(DependencyProperty, Object) |
将 DependencyProperty 的值设置为对象。Sets the value of the DependencyProperty to the object. (继承自 DependencyObject) |
| SetValueBase(DependencyProperty, Object) |
通过跳过 DependencyProperty,将 Object 的值设置为指定的 SetValue(DependencyProperty, Object)。Sets the value of the DependencyProperty to the specified Object, bypassing the SetValue(DependencyProperty, Object). (继承自 DependencyObject) |
| ToString() |
提供表示此实例的字符串。Provides a string that represents this instance. (继承自 Activity) |
| TrackData(Object) |
向运行时跟踪基础结构通知有关挂起跟踪的信息。Informs the run-time tracking infrastructure of pending tracking information. (继承自 Activity) |
| TrackData(String, Object) |
向运行时跟踪基础结构通知有关挂起跟踪的信息。Informs the run-time tracking infrastructure of pending tracking information. (继承自 Activity) |
| Uninitialize(IServiceProvider) |
当活动从 Closed 状态转换到 Initialized 状态时,由工作流运行时引擎调用。Called by the workflow runtime engine when an activity transitions into the Closed state from the Initialized state. (继承自 CompositeActivity) |
| UnregisterForStatusChange(DependencyProperty, IActivityEventListener<ActivityExecutionStatusChangedEventArgs>) |
注销状态更改事件的指定 DependencyProperty。Un-registers the specified DependencyProperty for the status change event. (继承自 Activity) |
事件
| Canceling |
在取消活动执行时发生。Occurs when the activity execution is canceled. (继承自 Activity) |
| Closed |
在 Activity 完成执行时发生。Occurs when an Activity has completed execution. (继承自 Activity) |
| Compensating |
在 Activity 上运行补偿方法时发生。Occurs when running a compensation method on the Activity. (继承自 Activity) |
| Executing |
在运行 Activity 时发生。Occurs when the Activity is run. (继承自 Activity) |
| Faulting |
在实例的运行期间引发异常时发生。Occurs when an exception is raised during the running of the instance. (继承自 Activity) |
| StatusChanged |
在运行中的 ActivityExecutionStatus 的 Activity 更改时发生。Occurs when the ActivityExecutionStatus of a running Activity changes. (继承自 Activity) |
显式接口实现
| IActivityEventListener<ActivityExecutionStatusChangedEventArgs>.OnEvent(Object, ActivityExecutionStatusChangedEventArgs) |
定义发生订阅事件时的处理过程。Defines the processing procedure when the subscribed-to event occurs. (继承自 SequenceActivity) |
| IComponent.Disposed |
表示处理组件的“Disposed”事件的方法。Represents the method that handles the Disposed event of a component. (继承自 DependencyObject) |