WorkflowInstance.Terminate(String) Método
Definição
Encerra a instância de fluxo de trabalho de forma síncrona.Terminates the workflow instance in a synchronous manner.
public:
void Terminate(System::String ^ error);
public void Terminate (string error);
member this.Terminate : string -> unit
Public Sub Terminate (error As String)
Parâmetros
- error
- String
Uma descrição do motivo para encerrar a instância de fluxo de trabalho.A description of the reason for terminating the workflow instance.
Exceções
O mecanismo de runtime de fluxo de trabalho não está em execução.The workflow runtime engine is not running.
Exemplos
O exemplo de código a seguir demonstra como chamar Terminate em um WorkflowInstance objeto.The following code example demonstrates calling Terminate on a WorkflowInstance object.
// Create a workflow runtime
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a workflow instance
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow1));
// Start the workflow
workflowInstance.Start();
// Terminate the workflow, passing in a message
workflowInstance.Terminate("Workflow manually terminated");
' Create a workflow runtime
Dim workflowRuntime As New WorkflowRuntime()
' Create a workflow instance
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1))
' Start the workflow
workflowInstance.Start()
' Terminate the workflow, passing in a message
workflowInstance.Terminate("Workflow manually terminated")
Comentários
A instância de fluxo de trabalho é encerrada de maneira síncrona.The workflow instance is terminated in a synchronous manner. O host chama Terminate para encerrar a instância de fluxo de trabalho.The host calls Terminate to terminate the workflow instance. O mecanismo de tempo de execução de fluxo de trabalho limpa a instância de fluxo de trabalho na memória e informa ao serviço de persistência que a instância foi limpa da memória.The workflow runtime engine clears the in-memory workflow instance and informs the persistence service that the instance has been cleared from memory. Para o SqlWorkflowPersistenceService , isso significa que todas as informações de estado dessa instância de fluxo de trabalho são excluídas do banco de dados após o encerramento.For the SqlWorkflowPersistenceService, this means that all state information for that workflow instance is deleted from the database upon termination. Você não poderá recarregar a instância de fluxo de trabalho de um ponto de persistência armazenado anteriormente.You will not be able to reload the workflow instance from a previously stored persistence point.
Depois que a instância de fluxo de trabalho na memória é desmarcada e o serviço de persistência é informado sobre o encerramento, o Terminate método gera o WorkflowTerminated evento e passa reason a Message propriedade de um WorkflowTerminatedException contido no WorkflowTerminatedEventArgs .After the in-memory workflow instance is cleared and the persistence service is informed of the termination, the Terminate method raises the WorkflowTerminated event and passes reason in the Message property of a WorkflowTerminatedException contained in the WorkflowTerminatedEventArgs.
Terminate é diferente de Abort , enquanto Terminate limpa a instância de fluxo de trabalho na memória e informa o serviço de persistência do encerramento, Abort simplesmente limpa a instância de fluxo de trabalho na memória, que pode ser reiniciada a partir do último ponto de persistência.Terminate is different from Abort in that while Terminate clears the in-memory workflow instance and informs the persistence service of the termination, Abort simply clears the in-memory workflow instance, which can then be restarted from the last persistence point.