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();
    }
    }
    }
  • 相关阅读:
    【转载】面试70问 经典回答
    USB基础知识
    TCPDUMP 使用教程
    linux网络性能测试工具ipref安装与使用
    linux查看主板型号、CPU、显卡、硬盘等信息
    Curl请求慢
    mac与windows共享键盘鼠标(synergy)
    Tomcat 配置文件 server.xml
    jumpserver win终端无法添加
    进程占用情况记录
  • 原文地址:https://www.cnblogs.com/liulun/p/1654913.html
Copyright © 2011-2022 走看看