Share via


WorkflowQueuingService.Exists(IComparable) Méthode

Définition

Teste l'existence de la WorkflowQueue spécifiée.

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

Paramètres

queueName
IComparable

Nom de l'objet WorkflowQueue.

Retours

true si la WorkflowQueue existe ; sinon, false.

Exceptions

queueName est une référence Null (Nothing en Visual Basic).

Exemples

L'exemple de code suivant montre une méthode, nommée CreateQueue, qui initialise un objet WorkflowQueuingService en appelant la méthode ActivityExecutionContext.GetService. Le code utilise ensuite la méthode Exists pour déterminer si une WorkflowQueue portant un nom donné existe. Si l'élément n'existe pas, le code appelle la méthode CreateWorkflowQueue ; s'il existe, le code appelle la méthode GetWorkflowQueue.

Cet exemple de code fait partie de l'exemple du Kit de développement logiciel File Watcher Activity (SDK) et provient du fichier FileSystemEvent.cs. Pour plus d’informations, consultez Activité d’observateur du système de fichiers.

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

S’applique à

Voir aussi