Share via


WorkflowRuntime.WorkflowIdled 事件

定義

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

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

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

適用於