0 out of 1 rated this helpful - Rate this topic

WorkflowQueue Class

Represents a workflow queue.

System.Object
  System.Workflow.Runtime.WorkflowQueue

Namespace:  System.Workflow.Runtime
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)
public class WorkflowQueue

The WorkflowQueue type exposes the following members.

  Name Description
Public property Count Gets the number of items contained in the WorkflowQueue.
Public property Enabled Gets or sets a value that specifies whether the WorkflowQueue is enabled.
Public property QueueName Gets the name of the workflow queue.
Public property QueuingService Gets the queuing service associated with this WorkflowQueue.
Top
  Name Description
Public method Dequeue Removes and returns the object at the beginning of the WorkflowQueue.
Public method Enqueue Adds an object to the end of the WorkflowQueue.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Peek Returns the object at the beginning of the WorkflowQueue without removing it.
Public method RegisterForQueueItemArrived Registers a subscriber to the QueueItemArrived event.
Public method RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>) Registers a subscriber to the QueueItemAvailable event.
Public method RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>, String) Registers a subscriber to the QueueItemAvailable event.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method UnregisterForQueueItemArrived Unregisters a subscriber to the QueueItemArrived event.
Public method UnregisterForQueueItemAvailable Unregisters a subscriber to the QueueItemAvailable event.
Top
  Name Description
Public event QueueItemArrived Occurs when an item is delivered on this WorkflowQueue.
Public event QueueItemAvailable Occurs when an item is available on this WorkflowQueue.
Top

Workflow queues are used to pass messages between a host or host services and activities in a workflow. Any activity can create a WorkflowQueue by calling WorkflowQueuingService.CreateWorkflowQueue, and a host, a service, or another activity can call Enqueue to add an item to that WorkflowQueue. You can subscribe to the QueueItemAvailable event to be notified when an item arrives on the WorkflowQueue. You can use Peek to examine an item at the beginning of the WorkflowQueue and Dequeue to remove an item from the WorkflowQueue. Each WorkflowQueue is associated with a WorkflowQueuingService that you can use to perform other management operations on the WorkflowQueue, such as deleting the queue. QueuingService exposes the WorkflowQueuingService associated with this WorkflowQueue.

The following code example demonstrates how you can create a WorkflowQueue by calling the WorkflowQueuingService.GetWorkflowQueue method. It also uses the Count property to determine whether any messages exist in the current queue. Finally, the code uses the Dequeue method to remove and return the first object in the queue.

This code example is part of the File Watcher Activity SDK Sample from the FileSystemEvent.cs file. For more information, see File System Watcher Activity.


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;
}


.NET Framework

Supported in: 4, 3.5, 3.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ