WorkflowRuntime.StopRuntime Método

Definição

Interrompe o mecanismo de tempo de execução de fluxo de trabalho e os serviços de tempo de execução.Stops the workflow run-time engine and the run-time services.

public:
 void StopRuntime();
public void StopRuntime ();
member this.StopRuntime : unit -> unit
Public Sub StopRuntime ()

Exceções

O WorkflowRuntime já foi descartado.The WorkflowRuntime is already disposed of.

Exemplos

O exemplo de código a seguir demonstra como usar a WorkflowRuntime funcionalidade de um host de fluxo de trabalho.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. StopRuntime é chamado depois que o host concluir todo o processamento associado ao tempo de execução.StopRuntime is called after the host has completed all other processing associated with the runtime.

Este exemplo de código faz parte do exemplo de cancelamento de um fluxo de trabalho .This code example is part of the Canceling a Workflow sample.

static void Main()
{
    string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";

    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
        ExternalDataExchangeService dataService = new ExternalDataExchangeService();
        workflowRuntime.AddService(dataService);
        dataService.AddService(expenseService);

        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
        workflowRuntime.StartRuntime();

        workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
        workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
        workflowRuntime.WorkflowIdled += OnWorkflowIdled;
        workflowRuntime.WorkflowAborted += OnWorkflowAborted;

        Type type = typeof(SampleWorkflow1);
        WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
        workflowInstance.Start();

        waitHandle.WaitOne();

        workflowRuntime.StopRuntime();
    }
}
Shared Sub Main()
    Dim connectionString As String = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"
    Using workflowRuntime As New WorkflowRuntime()
        Dim dataService As New ExternalDataExchangeService()
        workflowRuntime.AddService(dataService)
        dataService.AddService(expenseService)

        workflowRuntime.AddService(New SqlWorkflowPersistenceService(connectionString))


        AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
        AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
        AddHandler workflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
        AddHandler workflowRuntime.WorkflowAborted, AddressOf OnWorkflowAborted


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

        waitHandle.WaitOne()

        workflowRuntime.StopRuntime()
    End Using
End Sub

Comentários

Esse método faz com que o mecanismo de tempo de execução do fluxo de trabalho descarregue cada uma de suas instâncias de fluxo de trabalho, interrompa todos os seus serviços derivados da WorkflowRuntimeService classe, defina IsStarted como false e gere o Stopped evento.This method causes the workflow run-time engine to unload each of its workflow instances, stop all of its services that are derived from the WorkflowRuntimeService class, set IsStarted to false, and raise the Stopped event.

Para desligar o WorkflowRuntime normalmente, chame StopRuntime antes de chamar Dispose .To shut down the WorkflowRuntime gracefully, call StopRuntime before you call Dispose.

Para obter mais informações, consulte o método Dispose.For more information, see the Dispose method.

Aplica-se a