Share via


WorkflowQueue.Dequeue Yöntem

Tanım

öğesinin başındaki WorkflowQueuenesnesini kaldırır ve döndürür.

public:
 System::Object ^ Dequeue();
public object Dequeue ();
member this.Dequeue : unit -> obj
Public Function Dequeue () As Object

Döndürülenler

öğesinin başından WorkflowQueuekaldırılan nesne.

Özel durumlar

Örnekler

Aşağıdaki kod örneği, yöntemini çağırarak nasıl oluşturabileceğinizi WorkflowQueueWorkflowQueuingService.GetWorkflowQueue gösterir. Ayrıca, geçerli kuyrukta Count herhangi bir ileti olup olmadığını belirlemek için özelliğini kullanır. Son olarak kod, kuyruktaki Dequeue ilk nesneyi kaldırmak ve döndürmek için yöntemini kullanır.

Bu kod örneği, FileSystemEvent.cs dosyasındaki Dosya İzleyicisi Etkinlik SDK Örneği'nin bir parçasıdır. Daha fazla bilgi için bkz. Dosya Sistemi İzleyicisi Etkinliği.

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

Açıklamalar

çağrısı Dequeueyapmadan önce öğesinin WorkflowQueue boş olup olmadığını denetleyebilirsiniz Count veya öğesini yakalayabilirsinizInvalidOperationException.

Şunlara uygulanır

Ayrıca bkz.