Module Module1 Class Program Shared WaitHandle As New AutoResetEvent(False) Shared Sub Main() Using workflowRuntime As New WorkflowRuntime() AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated Dim workflowInstance As WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow1)) workflowInstance.Start() WaitHandle.WaitOne() Console.ReadLine() End Using End Sub Shared Sub OnWorkflowCompleted(ByVal sender As Object, ByVal e As WorkflowCompletedEventArgs) WaitHandle.Set() End Sub Shared Sub OnWorkflowTerminated(ByVal sender As Object, ByVal e As WorkflowTerminatedEventArgs) Console.WriteLine(e.Exception.Message) WaitHandle.Set() End Sub End Class End Module