|
using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.Runtime;
using System.Threading;
namespace WorkflowInvoker
{
class Program
{
private static AutoResetEvent waitHandle = new AutoResetEvent(false);
static void Main(string[] args)
{
// Obtain a workflow runtime object.
WorkflowRuntime workflowRuntime = WorkflowFactory.GetWorkflowRuntime();
// Add the event handlers.
workflowRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(workflowIdled);
workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowCompleted);
workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(workflowTerminated);
// Print banner.
Console.WriteLine("Waiting for workflow completion.");
// Wait for the workflow to complete.
waitHandle.WaitOne();
// Print banner.
Console.WriteLine("Done.");
}
static void workflowTerminated(object sender,
WorkflowTerminatedEventArgs e)
{
Console.WriteLine("Workflow instance terminated, reason: '{0}'.", e.Exception.Message);
waitHandle.Set();
}
static void workflowCompleted(object sender, WorkflowCompletedEventArgs e)
{
}
static void workflowIdled(object sender, WorkflowEventArgs e)
{
Console.WriteLine("Workflow instance idled.");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.