Partager via


TrackingService Constructeur

Définition

Lors de l'implémentation dans une classe dérivée, initialise une nouvelle instance de la classe TrackingService.

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

Exemples

L'exemple suivant indique comment créer une nouvelle instance d'un objet TerminationTrackingService, d'un type qui dérive de TrackingService. Cet exemple est tiré de l'exemple du Kit de développement logiciel Termination Tracking Service (SDK). Pour plus d’informations, consultez l’exemple de service de suivi des interruptions.

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

S’applique à