WorkflowQueuingService.Exists(IComparable) Metoda

Definicja

Testy istnienia określonego WorkflowQueueelementu .

public:
 bool Exists(IComparable ^ queueName);
public bool Exists (IComparable queueName);
member this.Exists : IComparable -> bool
Public Function Exists (queueName As IComparable) As Boolean

Parametry

queueName
IComparable

Nazwa elementu WorkflowQueue.

Zwraca

truejeśli istniejeWorkflowQueue; w przeciwnym razie . false

Wyjątki

queueName jest odwołaniem o wartości null (Nothing w Visual Basic).

Przykłady

Poniższy przykład kodu przedstawia metodę o nazwie CreateQueue, która inicjuje WorkflowQueuingService obiekt przez wywołanie ActivityExecutionContext.GetService metody . Następnie kod używa Exists metody do określenia, czy obiekt WorkflowQueue o określonej nazwie istnieje. Jeśli nie istnieje, kod wywołuje metodę CreateWorkflowQueue . Jeśli kod wywołuje metodę GetWorkflowQueue .

Ten przykład kodu jest częścią przykładu zestawu SDK działania obserwatora plików z pliku FileSystemEvent.cs. Aby uzyskać więcej informacji, zobacz Działanie obserwatora systemu plików.

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

Dotyczy

Zobacz też