zoukankan      html  css  js  c++  java
  • 工作流学习笔记HelloWorld

    C#->控制台工作流->顺序工作流->拖放code->生成事件处理程序

    代码如下

    代码
    using System;
    using System.Workflow.Activities;

    namespace wf1
    {
    public sealed partial class Workflow1: SequentialWorkflowActivity
    {
    public Workflow1()
    {
    InitializeComponent();
    }

    private void codeActivity1_ExecuteCode(object sender, EventArgs e)
    {
    System.Threading.Thread.Sleep(
    6000);
    Console.WriteLine(
    "hello world");
    }
    }

    }

    对program.cs内容修改如下

    代码
    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 wf1
    {
    class Program
    {
    static void Main(string[] args)
    {
    using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
    AutoResetEvent waitHandle
    = new AutoResetEvent(false);
    //工作流完成时触发
    workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
    {
    //通知waitHandle,释放控制台应用程序
    waitHandle.Set();
    };
    //工作流发生错误时触发
    workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
    {
    Console.WriteLine(e.Exception.Message);
    waitHandle.Set();
    };
    //创建工作流的实例并启动工作流
    WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(wf1.Workflow1));
    instance.Start();
    //让控制台等待工作流的完成
    waitHandle.WaitOne();
    }
    Console.ReadKey();
    }
    }
    }
  • 相关阅读:
    函数Sort()
    数据窗口中数值型对象的显示格式
    函数IsValid()
    20130109显示器无反应
    DropDownPictureListBox设置默认项
    大数据
    字符串函数Mid()
    Jquery获取当前元素所在表格的行列数
    关于模式窗口中treeView问题
    格式化字符串长度 超出指定长度用....代替
  • 原文地址:https://www.cnblogs.com/liulun/p/1654913.html
Copyright © 2011-2022 走看看