HandleExternalEventActivity.CorrelationToken 属性
定义
获取或设置到 CorrelationToken 的绑定。Gets or sets the binding to a CorrelationToken.
public:
virtual property System::Workflow::Runtime::CorrelationToken ^ CorrelationToken { System::Workflow::Runtime::CorrelationToken ^ get(); void set(System::Workflow::Runtime::CorrelationToken ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Workflow.Activities.CorrelationTokenTypeConverter))]
public virtual System.Workflow.Runtime.CorrelationToken CorrelationToken { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Workflow.Activities.CorrelationTokenTypeConverter))>]
member this.CorrelationToken : System.Workflow.Runtime.CorrelationToken with get, set
Public Overridable Property CorrelationToken As CorrelationToken
属性值
此属性用于基于事件的负载将事件与继承 IEventActivity 的正确活动建立关联。This property is used to correlate an event to the correct IEventActivity-inherited activity based on the payload of the event. 例如,当单个工作流实例同时侦听同一事件的多个实例时,可以使用 CorrelationToken 属性将事件路由到该工作流实例中正确的活动。For example, when a single workflow instance is listening for multiple instances of the same event at the same time, the CorrelationToken property is used to route the event to the proper activity in that workflow instance.
不要将此关联与将事件与正确的工作流实例建立关联相混淆。This correlation should not be confused with correlating an event to the correct workflow instance. 与正确的工作流实例建立关联是通过将事件发送到显式工作流实例并使用 InstanceId 属性正确地标识正确的工作流实例来完成的。The correlation to the correct workflow instance is done by sending the event to an explicit workflow instance and using the InstanceId property to properly identify the correct workflow instance.
有关相关的示例,请参阅 相关的本地服务示例。For an example of correlation, see the Correlated Local Service Sample.
- 属性
示例
以下示例演示如何访问 CorrelationToken 的 HandleExternalEventActivity 属性。The following example shows how to access the CorrelationToken property of a HandleExternalEventActivity. 此示例摘自 CorrelatedLocalServiceWorkflow.designer.cs 文件的“相关的本地服务”SDK 示例。This example is from the Correlated Local Service SDK sample, from the CorrelatedLocalServiceWorkflow.designer.cs file. 有关详细信息,请参阅 相关本地服务示例。For more information, see Correlated Local Service Sample.
this.taskCompleted2.CorrelationToken = correlationtoken1;
Me.taskCompleted2.CorrelationToken = correlationtoken1