WWF 工作流学习笔记(四进街)

我的第一个工作流  \"Hello Word\"
新建状态机工作流项目\"WorkflowLibrary1\"
  private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        {
           // System.Windows.Forms.MessageBox.Show(\"sdlkalksadfasdF\");
            CodeActivity cd = new CodeActivity();
            Console.WriteLine(\"Hello, from \'{0}\'.\\nI\'m an instance of the {1} class.\",cd.Name, cd.ToString());


        }
2、添加新项目(控制台程序)\"ConsoleApplication1\"代码如下:
 class Program
    {
        static AutoResetEvent waitHandle = new AutoResetEvent(false);
        static void Main(string[] args)
        {
            //Form1 fr = new Form1();
            //fr.Show();
            WorkflowRuntime wn = new WorkflowRuntime();
            wn.StartRuntime();

            wn.WorkflowCompleted +=new EventHandler<WorkflowCompletedEventArgs>(OnWorkflowCompleted);
            Type type = typeof(WorkflowLibrary1.Workflow1);
            WorkflowInstance inst = wn.CreateWorkflow(type);
            inst.Start();
            //wn.CreateWorkflow(type);
           
            waitHandle.WaitOne();
           
            wn.StopRuntime();
            Console.WriteLine(\"\");
            Console.WriteLine(\"\");
            Console.WriteLine(\"==========================\");
            Console.WriteLine(\"Press any key to exit.\");
            Console.WriteLine(\"==========================\");
            Console.ReadLine();
        }

        static void OnWorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
        {
            waitHandle.Set();
            //throw new Exception(\"The method Or operation is not implemented.\");
        }
    }
实现结果
[img=http://www.microsoft.com/china/MSDN/library/Windev/WindowsVista/art/wwfgetstart_04.png]

posted @ 2007-04-16 22:31  理财顾问  阅读(639)  评论(0编辑  收藏  举报