locked
How to create and run a workflow instance. RRS feed

  • Question

  • How to create and run a workflow instance.
    Friday, September 1, 2006 10:17 AM

Answers

  •  Kanhaiya wrote:
    How to create and run a workflow instance.


    Kanhaiya,

    Are you looking for something different (i.e. more specific to a given situation) than the usual code of starting the WF runtime (once) and later asking it to start the workflow instance for you?


    WorkflowRuntime workflowRuntime = new WorkflowRuntime("ConsoleApplication");
    AutoResetEvent waitHandle = new AutoResetEvent(false);
    workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
    {
       waitHandle.Set();
    };
    workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
    {
       Console.WriteLine(e.Exception.Message);
       waitHandle.Set();
    };

    WorkflowInstance instance = workflowRuntime.CreateWorkflow(
       typeof(MyWorkflowType)
    );
    instance.Start();

    waitHandle.WaitOne();


    Friday, September 1, 2006 12:37 PM