WorkflowRuntime.StopRuntime Método

Definición

Detiene el motor en tiempo de ejecución de flujo de trabajo y los servicios en tiempo de ejecución.

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

Excepciones

Ejemplos

El ejemplo de código siguiente muestra cómo se puede utilizar la funcionalidad WorkflowRuntime desde un host del flujo de trabajo. StopRuntime se llama después de que el host haya completado el resto del procesamiento asociado al tiempo de ejecución.

Este ejemplo de código forma parte del ejemplo Cancelar un flujo de trabajo .

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

Comentarios

Este método hace que el motor en tiempo de ejecución del flujo de trabajo descargue cada una de sus instancias de flujo de trabajo, detenga todos sus servicios derivados de la WorkflowRuntimeService clase , establezca en IsStartedfalsey genere el Stopped evento .

Para cerrar correctamente WorkflowRuntime, llame a StopRuntime antes de llamar a Dispose.

Para obtener más información, vea el método Dispose.

Se aplica a