WorkflowRuntime.WorkflowIdled 事件

定义

在工作流实例进入空闲状态后发生。

public:
 event EventHandler<System::Workflow::Runtime::WorkflowEventArgs ^> ^ WorkflowIdled;
public event EventHandler<System.Workflow.Runtime.WorkflowEventArgs> WorkflowIdled;
member this.WorkflowIdled : EventHandler<System.Workflow.Runtime.WorkflowEventArgs> 
Public Custom Event WorkflowIdled As EventHandler(Of WorkflowEventArgs) 
Public Event WorkflowIdled As EventHandler(Of WorkflowEventArgs) 

事件类型

示例

下面的代码示例演示如何使用工作流宿主中的 WorkflowRuntime 功能。 该代码将 WorkflowIdled 与一个事件处理程序即一个名为 OnWorkflowIdled 的方法相关联。

此代码示例是 取消工作流示例的一 部分。

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();
    }
}
Shared Sub Main()
    Dim connectionString As String = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"
    Using workflowRuntime As New WorkflowRuntime()
        Dim dataService As New ExternalDataExchangeService()
        workflowRuntime.AddService(dataService)
        dataService.AddService(expenseService)

        workflowRuntime.AddService(New SqlWorkflowPersistenceService(connectionString))


        AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
        AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
        AddHandler workflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
        AddHandler workflowRuntime.WorkflowAborted, AddressOf OnWorkflowAborted


        Dim workflowInstance As WorkflowInstance
        workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
        workflowInstance.Start()

        waitHandle.WaitOne()

        workflowRuntime.StopRuntime()
    End Using
End Sub

注解

在工作流实例进入空闲状态后,工作流运行时引擎引发 WorkflowIdled 事件;例如,工作流在等待 DelayActivity 活动完成时会引发该事件。

在此事件中,发送方包含 WorkflowRuntime,而 WorkflowEventArgs 包含与事件关联的 WorkflowInstance

有关处理事件的详细信息,请参阅 处理和引发事件

适用于