WorkflowQueue.Count Propiedad

Definición

Obtiene el número de elementos contenidos en WorkflowQueue.

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

Valor de propiedad

El número de elementos en la cola de flujo de trabajo.

Ejemplos

En el siguiente código de ejemplo se muestra cómo crear un WorkflowQueue llamando al método WorkflowQueuingService.GetWorkflowQueue. También utiliza la propiedad Count para determinar si los mensajes existen en la cola actual. Finalmente, el código utiliza el método Dequeue para quitar y devolver el primer objeto en la cola.

Este ejemplo de código forma parte de la muestra de SDK de actividad de observador de archivo del archivo FileSystemEvent.cs. Para obtener más información, vea Actividad del monitor del sistema de archivos.

private bool ProcessQueueItem(ActivityExecutionContext context)
{
    WorkflowQueuingService qService = context.GetService<WorkflowQueuingService>();
    if (!qService.Exists(this.QueueName))
    {
        return false;
    }

    WorkflowQueue queue = qService.GetWorkflowQueue(this.QueueName);

    // If the queue has messages, then process the first one
    if (queue.Count == 0)
    {
        return false;
    }

    FileWatcherEventArgs e = (FileWatcherEventArgs)queue.Dequeue();

    // Raise the FileSystemEvent
    base.RaiseGenericEvent<FileWatcherEventArgs>(FileSystemEvent.FileWatcherEventHandlerEvent, this, e);

    DoUnsubscribe(context, this);
    DeleteQueue(context);
    return true;
}
Private Function ProcessQueueItem(ByVal context As ActivityExecutionContext) As Boolean

    Dim qService As WorkflowQueuingService = context.GetService(Of WorkflowQueuingService)()

    If Not qService.Exists(Me.QueueName) Then
        Return False
    End If

    Dim Queue As WorkflowQueue = qService.GetWorkflowQueue(Me.QueueName)

    ' If the queue has messages, then process the first one
    If Queue.Count = 0 Then
        Return False
    End If

    Dim e As FileWatcherEventArgs = CType(Queue.Dequeue(), FileWatcherEventArgs)

    ' Raise the FileSystemEvent
    MyBase.RaiseGenericEvent(Of FileWatcherEventArgs)(FileSystemEvent.FileWatcherEventHandlerEvent, Me, e)
    DoUnsubscribe(context, Me)
    DeleteQueue(context)
    Return True
End Function

Se aplica a

Consulte también