Ebeworld’s Weblog

Trying to create

Hello World WPF with IfElse

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading;

using System.Workflow.Runtime;

using System.Workflow.Runtime.Hosting;

 

namespace MyHelloWorld2

{

    class Program

    {

        static void Main(string[] args)

        {

            using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())

            {

                AutoResetEvent waitHandle = new AutoResetEvent(false);

                string message = string.Empty;

                Dictionary<String, Object> inParams = new Dictionary<string, Object>();

                //inParams.Add(“FirstName”, “Todd”);

 

                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) 

                {

                    message = (string)e.OutputParameters["Message"];

                    waitHandle.Set();

                };

                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)

                {

                    Console.WriteLine(e.Exception.Message);

                    waitHandle.Set();

                };

 

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(MyHelloWorld2.Workflow1), inParams);

                instance.Start();

 

                waitHandle.WaitOne();

                Console.WriteLine(message);

            }

        }

    }

}

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace MyHelloWorld2
{
    public sealed partial class Workflow1 : SequentialWorkflowActivity
    {
        private String fistName;
        private String message;
        public String FirstName
        {
            set
            {
                this.fistName = value;
            }
        }
        public String Message
        {
            get
            {
                return this.message;
            }
        }
        public Workflow1()
        {
            InitializeComponent();
        }
        private void hasName(object sender, ConditionalEventArgs e)
        {
            if (!String.IsNullOrEmpty(this.fistName))
            {
                e.Result = true;
            }
        }
        private void createMessage_ExecuteCode(object sender, EventArgs e)
        {
            this.message = “Hello” + fistName;
        }
        private void createMessage2_ExecuteCode(object sender, EventArgs e)
        {
            this.message = “Hello, World!”;
        }
    }
}

January 10, 2009 Posted by ebeworld | WWF | | No Comments Yet