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();
    }
    }
    }
  • 相关阅读:
    Bitcode设置 编译问题
    NSDate 时间比较...等
    MagicalRecord 多表关联数据操作
    简单的 同步 异步 请求
    pod创建的工程找不到库
    UITableViewCell 自适应高度 ios8特性
    iOS中nil、Nil、NULL、NSNull详解(转)
    c++ wchar_t 与char 直接的转换【转】
    VS 2010 转到COFF期间失败。
    OpenCV中阈值(threshold)函数: threshold 。
  • 原文地址:https://www.cnblogs.com/liulun/p/1654913.html
Copyright © 2011-2022 走看看