added samples
[windows-sources.git] / sdk / samples / CrossTechnologySamples / WFCallingWCF / workflow / program.cs
blob05d4fb596fca2764953590f8215b2f115a1cc58d
1 #region Using directives
3 using System;
4 using System.Collections.Generic;
5 using System.Text;
6 using System.Threading;
7 using System.Workflow.Runtime;
8 using System.Workflow.Runtime.Hosting;
9 using Microsoft.ServiceModel.Samples.Properties;
11 #endregion
13 namespace Microsoft.ServiceModel.Samples
15 class Program
17 static AutoResetEvent waitHandle = new AutoResetEvent(false);
19 static void Main(string[] args)
21 string input = "Hello world";
22 Console.WriteLine("Input parameter for this workflow is {0}", input);
23 Dictionary<string, object> parameters = new Dictionary<string, object>();
24 parameters.Add("Input", input);
26 WorkflowRuntime workflowRuntime = new WorkflowRuntime();
28 workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted);
29 workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(workflowRuntime_WorkflowTerminated);
31 WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Workflow1), parameters);
32 Console.WriteLine("Starting workflow");
33 instance.Start();
35 waitHandle.WaitOne();
37 Console.WriteLine("Press <ENTER> to terminate program.");
38 Console.ReadLine();
41 static void workflowRuntime_WorkflowTerminated(object sender, WorkflowTerminatedEventArgs e)
43 Console.WriteLine(e.Exception.Message);
44 waitHandle.Set();
48 static void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
50 Console.WriteLine("Workflow completed");
51 string returnValue = (string)e.OutputParameters["ReturnValue"];
52 Console.WriteLine("The ReturnValue for this workflow was {0}", returnValue);
53 waitHandle.Set();