工作流运行时引擎为工作流提供的可配置执行环境

static void Main()
  {
      string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";
  
      using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
      {
          ExternalDataExchangeService dataService = new ExternalDataExchangeService();
          workflowRuntime.AddService(dataService);
          dataService.AddService(expenseService);
  
          workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
          workflowRuntime.StartRuntime();
  
          workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
          workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
          workflowRuntime.WorkflowIdled += OnWorkflowIdled;
          workflowRuntime.WorkflowAborted += OnWorkflowAborted;
  
          Type type = typeof(SampleWorkflow1);
          WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
          workflowInstance.Start();
  
          waitHandle.WaitOne();
  
          workflowRuntime.StopRuntime();
      }
  }

 示例演示如何使用工作流宿主中的 WorkflowRuntime 功能。 该代码示例演示如何使用 WorkflowRuntime 构造函数和 AddService、 StartRuntime 和 StopRuntime 方法。 该代码还给出了建议采用的方法,即如何使用 WorkflowInstance 方法在工作流宿主中创建 CreateWorkflow 对象。 它还演示如何为 WorkflowCompleted、 WorkflowIdled 和 WorkflowTerminated 事件设置事件处理程序

posted @ 2011-12-23 10:05  nnsword  阅读(531)  评论(0编辑  收藏  举报