WorkflowRuntime.WorkflowIdled 事件

定義

在工作流程執行個體進入閒置 (Idle) 狀態時發生。

C#
public event EventHandler<System.Workflow.Runtime.WorkflowEventArgs> WorkflowIdled;

事件類型

範例

下列程式碼範例示範如何從工作流程主機使用 WorkflowRuntime 功能。 此程式碼會使 WorkflowIdled 與事件處理常式 (名稱為 OnWorkflowIdled 的方法) 產生關聯。

此程式碼範例是 取消工作流程 範例的一部分。

C#
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();
    }
}

備註

工作流程執行階段引擎會在工作流程執行個體進入閒置狀態時引發 WorkflowIdled 事件。例如,在工作流程等待 DelayActivity 活動完成時。

對於這個事件,傳送者會包含 WorkflowRuntime,而 WorkflowEventArgs 則包含事件關聯的 WorkflowInstance

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1