WorkflowInstance.Start Método
Definição
Inicia a execução da instância de fluxo de trabalho.Starts the execution of the workflow instance.
public:
void Start();
public void Start ();
member this.Start : unit -> unit
Public Sub Start ()
Exceções
O mecanismo de runtime de fluxo de trabalho não está em execução.The workflow runtime engine is not running.
- ou --or-
A instância de fluxo de trabalho já foi iniciada.The workflow instance has already been started.
Exemplos
O exemplo de código a seguir demonstra como você pode usar o Start método para iniciar um WorkflowInstance em um host de fluxo de trabalho.The following code example demonstrates how you can use the Start method to start a WorkflowInstance in a workflow host. O código cria uma instância do WorkflowRuntime , adiciona serviços ao tempo de execução e, em seguida, demonstra a maneira recomendada para criar um WorkflowInstance objeto.The code creates an instance of the WorkflowRuntime, adds services to the runtime, and then demonstrates the recommended way to create a WorkflowInstance object. Ele cria um Type objeto e o converte em um dos objetos de fluxo de trabalho aos quais o host está associado.It creates a Type object and casts it to one of the workflow objects with which the host is associated. O código a seguir inicializa WorkflowInstance chamando o CreateWorkflow método e passando o tipo criado anteriormente para ele.The code next initializes WorkflowInstance by calling the CreateWorkflow method and passing the previously created type to it. O WorkflowInstance é iniciado com a Start chamada de método.The WorkflowInstance is started with the Start method call.
Este exemplo de código faz parte do exemplo de cancelamento de um SDK de fluxo de trabalho do arquivo Program.cs.This code example is part of the Canceling a Workflow SDK sample from the Program.cs file. Para obter mais informações, consulte cancelando um fluxo de trabalho.For more information, see Canceling a Workflow.
Type type = typeof(SampleWorkflow1);
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();
Dim workflowInstance As WorkflowInstance
workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
workflowInstance.Start()
Comentários
Start chama ExecuteActivity a atividade raiz desta instância de fluxo de trabalho.Start calls ExecuteActivity on the root activity of this workflow instance. Se Start o encontrar uma exceção, ela encerrará a instância do fluxo de trabalho chamando Terminate com a Message propriedade da exceção passada como o motivo do encerramento.If Start encounters an exception, it terminates the workflow instance by calling Terminate with the Message property of the exception passed as the reason for the termination.