Share via


WorkflowQueuingService.CreateWorkflowQueue(IComparable, Boolean) 方法

定義

使用指定的名稱和交易範圍建立 WorkflowQueue

public:
 System::Workflow::Runtime::WorkflowQueue ^ CreateWorkflowQueue(IComparable ^ queueName, bool transactional);
public System.Workflow.Runtime.WorkflowQueue CreateWorkflowQueue (IComparable queueName, bool transactional);
member this.CreateWorkflowQueue : IComparable * bool -> System.Workflow.Runtime.WorkflowQueue
Public Function CreateWorkflowQueue (queueName As IComparable, transactional As Boolean) As WorkflowQueue

參數

queueName
IComparable

佇列的名稱。

transactional
Boolean

指定 WorkflowQueue 在目前交易範圍外是否可見的值。

傳回

WorkflowQueue 物件。

例外狀況

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

具有 WorkflowQueue 指定之名稱的 queueName 已經存在。

範例

下列程式碼範例將示範名為 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

備註

使用指定的 WorkflowQueue 建立 queueName。 如果可異動為 true,只有在目前異動內才可以看見 WorkflowQueue

適用於

另請參閱