Represents a workflow queue.
Assembly: System.Workflow.Runtime (in System.Workflow.Runtime.dll)
Thetype exposes the following members.
|Dequeue||Removes and returns the object at the beginning of the .|
|Enqueue||Adds an object to the end of the .|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|Peek||Returns the object at the beginning of the without removing it.|
|RegisterForQueueItemArrived||Registers a subscriber to the QueueItemArrived event.|
|RegisterForQueueItemAvailable(IActivityEventListener(Of QueueEventArgs))||Registers a subscriber to the QueueItemAvailable event.|
|RegisterForQueueItemAvailable(IActivityEventListener(Of QueueEventArgs), String)||Registers a subscriber to the QueueItemAvailable event.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|UnregisterForQueueItemArrived||Unregisters a subscriber to the QueueItemArrived event.|
|UnregisterForQueueItemAvailable||Unregisters a subscriber to the QueueItemAvailable event.|
Workflow queues are used to pass messages between a host or host services and activities in a workflow. Any activity can create a by calling WorkflowQueuingService.CreateWorkflowQueue, and a host, a service, or another activity can call Enqueue to add an item to that . You can subscribe to the QueueItemAvailable event to be notified when an item arrives on the . You can use Peek to examine an item at the beginning of the and Dequeue to remove an item from the . Each is associated with a WorkflowQueuingService that you can use to perform other management operations on the , such as deleting the queue. QueuingService exposes the WorkflowQueuingService associated with this .
The following code example demonstrates how you can create a 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 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
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