TrackingChannel.Send(TrackingRecord) 方法


在派生类中实现时,在 TrackingRecord 上发送 TrackingChannelWhen implemented in a derived class, sends a TrackingRecord on the TrackingChannel.

protected public:
 abstract void Send(System::Workflow::Runtime::Tracking::TrackingRecord ^ record);
protected internal abstract void Send (System.Workflow.Runtime.Tracking.TrackingRecord record);
abstract member Send : System.Workflow.Runtime.Tracking.TrackingRecord -> unit
Protected Friend MustOverride Sub Send (record As TrackingRecord)



要发送的 TrackingRecordThe TrackingRecord to send.


下面的示例演示 Send 方法的实现。The following example demonstrates an implementation of the Send method. 在此实现中,跟踪消息将在工作流终止时写入事件日志。In this implementation, tracking messages are written to the event log when a workflow terminates. 此示例摘自“终止跟踪服务”SDK 示例。This sample is from the Termination Tracking Service SDK sample. 有关详细信息,请参阅 终止跟踪服务示例For more information, see Termination Tracking Service Sample.

/// <summary>
/// Receives tracking events.  Instance terminated events are written to the event log.
/// </summary>
protected override void Send(TrackingRecord record)
    WorkflowTrackingRecord instanceTrackingRecord = record as WorkflowTrackingRecord;

    if ((null == instanceTrackingRecord) || (TrackingWorkflowEvent.Terminated != instanceTrackingRecord.TrackingWorkflowEvent))

    // Create an EventLog instance and assign its source.
    EventLog log = new EventLog();
    log.Source = sourceValue;

    // Write an informational entry to the event log.
    TrackingWorkflowTerminatedEventArgs terminatedEventArgs = instanceTrackingRecord.EventArgs as TrackingWorkflowTerminatedEventArgs;

    StringBuilder message = new StringBuilder(512);
    message.AppendLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Workflow instance {0} has been terminated.", parametersValue.InstanceId.ToString()));

    if (null != terminatedEventArgs.Exception)

    log.WriteEntry(message.ToString(), EventLogEntryType.Warning);
'/ <summary>
'/ Receives tracking events.  Instance terminated events are written to the event log.
'/ </summary>
Protected Overrides Sub Send(ByVal record As TrackingRecord)

    Dim instanceTrackingRecord As WorkflowTrackingRecord = CType(record, WorkflowTrackingRecord)

    If instanceTrackingRecord Is Nothing Or Not TrackingWorkflowEvent.Terminated = instanceTrackingRecord.TrackingWorkflowEvent Then
    End If

    ' Create an EventLog instance and assign its source.
    Dim log As New EventLog()
    log.Source = sourceValue

    ' Write an informational entry to the event log.  
    Dim terminatedEventArgs As TrackingWorkflowTerminatedEventArgs = CType(instanceTrackingRecord.EventArgs, TrackingWorkflowTerminatedEventArgs)

    Dim Message As New StringBuilder(512)
    Message.AppendLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Workflow instance 0} has been terminated.", parametersValue.InstanceId.ToString()))

    If terminatedEventArgs.Exception Is Nothing Then
    End If

    log.WriteEntry(Message.ToString(), EventLogEntryType.Warning)
End Sub


当匹配了 Send 中的跟踪点时,运行时跟踪基础结构调用 TrackingRecordTrackingChannel 上传递 TrackingProfileThe runtime tracking infrastructure calls Send to deliver a TrackingRecord on the TrackingChannel when it matches a track point in a TrackingProfile. 您可以按照应用程序需求指示的任何方式处理在 TrackingChannel 上发送的跟踪信息。You can treat the tracking information sent on the TrackingChannel in whatever manner the requirements of your application dictate.