Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Start Method

WorkflowInstance.Start Method

Starts the execution of the workflow instance.

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

public void Start()

ExceptionCondition
InvalidOperationException

The workflow runtime engine is not running.

-or-

The workflow instance has already been started.

Start calls ExecuteActivity on the root activity of this workflow instance. 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.

The following code example demonstrates how you can use the Start method to start a WorkflowInstance in a workflow host. The code creates an instance of the WorkflowRuntime, adds services to the runtime, and then demonstrates the recommended way to create a WorkflowInstance object. It creates a Type object and casts it to one of the workflow objects with which the host is associated. The code next initializes WorkflowInstance by calling the CreateWorkflow method and passing the previously created type to it. The WorkflowInstance is started with the Start method call.

This code example is part of the Canceling a Workflow SDK sample from the Program.cs file. For more information, see Canceling a Workflow.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0
Show:
© 2015 Microsoft