TrackingService 构造函数

定义

在派生类中实现时,初始化 TrackingService 类的新实例。

protected:
 TrackingService();
protected TrackingService ();
Protected Sub New ()

示例

下面的示例演示如何为具有从 TerminationTrackingService 派生的类型的 TrackingService 对象创建新实例。 此示例摘自“终止跟踪服务”SDK 示例。 有关详细信息,请参阅 终止跟踪服务示例

using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
    AutoResetEvent waitHandle = new AutoResetEvent(false);
    NameValueCollection parameters = new NameValueCollection();
    parameters.Add("EventSource", eventSource);

    workflowRuntime.AddService(new TerminationTrackingService(parameters));
    workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
    workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
    {
        Console.WriteLine(e.Exception.Message);
        waitHandle.Set();
    };

    WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(SampleWorkflow));
    instance.Start();

    waitHandle.WaitOne();
}
Using workflowRuntime As New WorkflowRuntime()

    Dim waitHandle As New AutoResetEvent(False)
    Dim parameters As New NameValueCollection()
    parameters.Add("EventSource", eventSource)

    workflowRuntime.AddService(New TerminationTrackingService(parameters))
    AddHandler workflowRuntime.WorkflowCompleted, AddressOf WorkflowRuntime_WorkflowCompleted
    AddHandler workflowRuntime.WorkflowTerminated, AddressOf WorkflowRuntime_WorkflowTerminated

    Dim instance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
    instance.Start()

    waitHandle.WaitOne()
End Using

适用于