Beispiel #1
0
        /// <summary>
        /// Basic use of WorkflowInvoker to execute a workflow
        /// using properties to set input arguments
        /// </summary>
        private static void BasicWorkflowInvokerProperties()
        {
            Console.WriteLine("Host: About to run workflow - Thread:{0}",
                              System.Threading.Thread.CurrentThread.ManagedThreadId);

            try
            {
                HostingDemoWorkflow wf = new HostingDemoWorkflow();
                wf.ArgNumberToEcho = 1001;
                IDictionary <String, Object> output = WorkflowInvoker.Invoke(wf);

                Console.WriteLine("Host: Workflow completed - Thread:{0} - {1}",
                                  System.Threading.Thread.CurrentThread.ManagedThreadId,
                                  output["Result"]);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Host: Workflow exception:{0}:{1}",
                                  exception.GetType(), exception.Message);
            }
        }
Beispiel #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Int32 testNumber = 0;

            if (Int32.TryParse(TextBox1.Text, out testNumber))
            {
                StringWriter writer = new StringWriter();
                try
                {
                    writer.WriteLine("Host: About to run workflow - Thread:{0}",
                                     System.Threading.Thread.CurrentThread.ManagedThreadId);

                    HostingDemoWorkflow          wf     = new HostingDemoWorkflow();
                    IDictionary <String, Object> output =
                        WorkflowInvoker.Invoke(wf, new Dictionary <String, Object>
                    {
                        { "ArgNumberToEcho", 1001 },
                        { "ArgTextWriter", writer },
                    });

                    Label2.Text = (String)output["Result"];

                    writer.WriteLine(
                        "Host: Workflow completed - Thread:{0} - {1}",
                        System.Threading.Thread.CurrentThread.ManagedThreadId,
                        output["Result"]);
                }
                catch (Exception exception)
                {
                    writer.WriteLine("Host: Workflow exception:{0}:{1}",
                                     exception.GetType(), exception.Message);
                }

                //dump the contents of the writer
                TextBox2.Text = writer.ToString();
            }
        }