Compartilhar via


TrackingService Construtor

Definição

Quando implementado em uma classe derivada, inicializa uma nova instância da classe TrackingService.

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

Exemplos

O exemplo a seguir mostra como criar uma nova instância de um TerminationTrackingService objeto, de um tipo que deriva de TrackingService. Este exemplo é do exemplo do SDK do Serviço de Acompanhamento de Terminação. Para obter mais informações, consulte Exemplo do Serviço de Acompanhamento de Terminação.

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

Aplica-se a