Share via


WorkflowQueuingService.GetWorkflowQueue(IComparable) 方法

定義

擷取指定的 WorkflowQueue

public:
 System::Workflow::Runtime::WorkflowQueue ^ GetWorkflowQueue(IComparable ^ queueName);
public System.Workflow.Runtime.WorkflowQueue GetWorkflowQueue (IComparable queueName);
member this.GetWorkflowQueue : IComparable -> System.Workflow.Runtime.WorkflowQueue
Public Function GetWorkflowQueue (queueName As IComparable) As WorkflowQueue

參數

queueName
IComparable

要擷取之 WorkflowQueue 的名稱。

傳回

WorkflowQueue 物件。

例外狀況

queueName 為 null 參考 (在 Visual Basic 中為 Nothing)。

範例

下列程式碼範例將示範名為 CreateQueue 的方法,此方法透過呼叫 WorkflowQueuingService 方法來初始化 ActivityExecutionContext.GetService 物件。 然後,此程式碼會使用 Exists 方法來判斷具有指定名稱的 WorkflowQueue 是否存在。 如果不存在,程式碼會呼叫 CreateWorkflowQueue 方法,否則呼叫 GetWorkflowQueue 方法。

這個程式碼範例是 FileSystemEvent.cs 檔案中<檔案監看員活動 SDK>範例的一部分。 如需詳細資訊,請參閱 檔案系統監看員活動

private WorkflowQueue CreateQueue(ActivityExecutionContext context)
{
    Console.WriteLine("CreateQueue");
    WorkflowQueuingService qService = context.GetService<WorkflowQueuingService>();

    if (!qService.Exists(this.QueueName))
    {
        qService.CreateWorkflowQueue(this.QueueName, true);
    }

    return qService.GetWorkflowQueue(this.QueueName);
}
Private Function CreateQueue(ByVal context As ActivityExecutionContext) As WorkflowQueue
    Console.WriteLine("CreateQueue")
    Dim qService As WorkflowQueuingService = context.GetService(Of WorkflowQueuingService)()

    If Not qService.Exists(Me.queueName) Then
        qService.CreateWorkflowQueue(Me.queueName, True)
    End If

    Return qService.GetWorkflowQueue(Me.QueueName)
End Function

適用於

另請參閱