zoukankan      html  css  js  c++  java
  • 创建singleton模式的工作流引擎

    在一个系统推荐只有一个工作流引擎(当然也可以有多个)方便管理工作流实例,下面是单态模式的工作流工厂类文件。比较简单就不一一说明了
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Workflow.Runtime;
    using System.Workflow.Runtime.Tracking;
    using System.Configuration;

    namespace ConsoleApplicationForWWF
    {
    public static class WorkflowFactory
     {
    private static WorkflowRuntime wfr = null;

     private static object sys = new object();//同步锁对象

     public static WorkflowRuntime GetWorkflowRuntime()
     {
     lock (sys)
     {
    if (wfr == null)
     {
     AppDomain.CurrentDomain.ProcessExit += new EventHandler(StopWorkflowRuntime);
     AppDomain.CurrentDomain.DomainUnload += new EventHandler(StopWorkflowRuntime);
     wfr = new WorkflowRuntime();
     }
     return wfr;
    }
     }

    static void StopWorkflowRuntime(object sender, EventArgs e)
    {
    if (wfr != null)
     {
     if (wfr.IsStarted)
    {
    try
    {
     wfr.StopRuntime();
     }
     catch (ObjectDisposedException e2)
     {
     Console.WriteLine("Error ! the workflowruntime is not disposed :" + e2.ToString());
     }

    }
     }

     }
     
     }
    }

    本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。

  • 相关阅读:
    操作系统:中断和异常
    操作系统
    编程:判断一个点是否在三角形内部
    python 多态
    python super()函数:调用父类的构造方法
    python 继承机制(子类化内置类型)
    python 父类方法重写
    python 继承机制
    python 封装底层实现原理
    python 类的封装
  • 原文地址:https://www.cnblogs.com/zjypp/p/2319469.html
Copyright © 2011-2022 走看看