WorkflowInstance.GetWorkflowQueueData 메서드

정의

이 워크플로 인스턴스와 연결된 워크플로 큐에 대해 보류 중인 항목과 구독되는 활동을 포함하는 WorkflowQueueInfo 개체의 컬렉션을 가져옵니다.

public:
 System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::Runtime::WorkflowQueueInfo ^> ^ GetWorkflowQueueData();
public System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.Runtime.WorkflowQueueInfo> GetWorkflowQueueData ();
member this.GetWorkflowQueueData : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.Runtime.WorkflowQueueInfo>
Public Function GetWorkflowQueueData () As ReadOnlyCollection(Of WorkflowQueueInfo)

반환

ReadOnlyCollection<T> 개체의 WorkflowQueueInfo입니다.

예외

워크플로 런타임 엔진이 실행되고 있지 않은 경우

예제

다음 코드 예제에서는 GetWorkflowQueueData 메서드를 사용하여 WorkflowInstance 개체와 연결된 모든 워크플로 큐의 상태 정보를 가져오는 방법을 보여 줍니다. WorkflowIdled 이벤트가 발생하면 이 예제에서 정의된 OnWorkflowIdled 메서드가 호출됩니다. WorkflowInstance 속성을 사용하여 유휴 상태인 워크플로를 확인한 다음 GetWorkflowQueueData 메서드를 호출하여 워크플로 인스턴스에 대해 큐 항목 컬렉션을 가져옵니다. 이 코드는 컬렉션을 반복하여 워크플로를 유휴 상태로 만든 이벤트를 기다리고 있는 활동을 확인합니다. 그런 다음 이벤트 큐 항목의 이름과 함께 EnqueueItem 메서드를 사용하여 워크플로 큐에 예외를 보냅니다.

이 코드 예제는 Program.cs 파일에 있는 Canceling a Workflow SDK 샘플의 일부입니다. 자세한 내용은 워크플로 취소 하면합니다.

static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
    WorkflowInstance workflow = e.WorkflowInstance;

    Console.WriteLine("\n...waiting for 3 seconds... \n");
    Thread.Sleep(3000);

    // what activity is blocking the workflow
    ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData();
    foreach (WorkflowQueueInfo q in wqi)
    {
        EventQueueName eq = q.QueueName as EventQueueName;
        if (eq != null)
        {
            // get activity that is waiting for event
            ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames;
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]);

            // this event is never going to arrive eg. employee left the company
            // lets send an exception to this queue
            // it will either be handled by exception handler that was modeled in workflow
            // or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive");
            Console.WriteLine("Host: Cancel workflow with unhandled exception");
            workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null);
        }
    }
}
Shared Sub OnWorkflowIdled(ByVal sender As Object, ByVal e As WorkflowEventArgs)
    Dim workflow As WorkflowInstance = e.WorkflowInstance

    Console.WriteLine(vbCrLf + "...waiting for 3 seconds... " + vbCrLf)
    Thread.Sleep(3000)

    ' what activity is blocking the workflow
    Dim wqi As ReadOnlyCollection(Of WorkflowQueueInfo) = workflow.GetWorkflowQueueData()
    For Each q As WorkflowQueueInfo In wqi

        Dim eq As EventQueueName = TryCast(q.QueueName, EventQueueName)

        If eq IsNot Nothing Then
            ' get activity that is waiting for event
            Dim blockedActivity As ReadOnlyCollection(Of String) = q.SubscribedActivityNames
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity(0))

            ' this event is never going to arrive eg. employee left the company
            ' lets send an exception to this queue
            ' it will either be handled by exception handler that was modeled in workflow
            ' or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive")
            Console.WriteLine("Host: Cancel workflow with unhandled exception")
            workflow.EnqueueItem(q.QueueName, New Exception("ExitWorkflowException"), Nothing, Nothing)
        End If
    Next
End Sub

설명

GetWorkflowQueueData는 이 워크플로 인스턴스와 연결된 한 워크플로 큐의 상태에 대한 정보를 각각 포함하는 WorkflowQueueInfo 개체의 컬렉션을 반환합니다. WorkflowQueueInfo.ItemsWorkflowQueue에 대한 보류 중인 항목을 포함하고 WorkflowQueueInfo.SubscribedActivityNamesWorkflowQueue의 항목 전달에 대해 구독되는 활동의 목록을 포함합니다.

적용 대상

추가 정보