WorkflowQueue.RegisterForQueueItemAvailable Method

Definition

Registers a subscriber to the QueueItemAvailable event.

Overloads

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>)

Registers a subscriber to the QueueItemAvailable event.

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>, String)

Registers a subscriber to the QueueItemAvailable event.

Remarks

You can use the overloaded RegisterForQueueItemAvailable methods to register a subscriber for the QueueItemAvailable event. The QueueItemAvailable event is used to notify subscribers that an item has been delivered (in an asynchronous manner) to this WorkflowQueue.

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>)

Registers a subscriber to the QueueItemAvailable event.

public:
 void RegisterForQueueItemAvailable(System::Workflow::ComponentModel::IActivityEventListener<System::Workflow::ComponentModel::QueueEventArgs ^> ^ eventListener);
public void RegisterForQueueItemAvailable (System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.QueueEventArgs> eventListener);
member this.RegisterForQueueItemAvailable : System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.QueueEventArgs> -> unit
Public Sub RegisterForQueueItemAvailable (eventListener As IActivityEventListener(Of QueueEventArgs))

Parameters

eventListener
IActivityEventListener<QueueEventArgs>

A subscriber for QueueEventArgs that implements the IActivityEventListener<T> interface.

Exceptions

eventListener is a null reference (Nothing in Visual Basic).

Examples

The following code example demonstrates how you can create a WorkflowQueue by calling the WorkflowQueuingService.GetWorkflowQueue method. It also uses the RegisterForQueueItemAvailable to register the specified listener.

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 Boolean DoSubscribe(ActivityExecutionContext context, IActivityEventListener<QueueEventArgs> listener)
{
    WorkflowQueue queue = CreateQueue(context);
    queue.RegisterForQueueItemAvailable(listener);

    FileWatcherService fileService = context.GetService<FileWatcherService>();
    this.subscriptionId = fileService.RegisterListener(this.QueueName, this.Path, this.Filter, this.NotifyFilter, this.IncludeSubdirectories);
    return (subscriptionId != Guid.Empty);
}
Private Function DoSubscribe(ByVal context As ActivityExecutionContext, ByVal listener As IActivityEventListener(Of QueueEventArgs)) As Boolean
    Dim Queue As WorkflowQueue = CreateQueue(context)
    Queue.RegisterForQueueItemAvailable(listener)

    Dim fileService As FileWatcherService = context.GetService(Of FileWatcherService)()
    Me.subscriptionId = fileService.RegisterListener(Me.queueName, Me.Path, Me.Filter, Me.NotifyFilter, Me.IncludeSubdirectories)
    Return Not subscriptionId = Guid.Empty
End Function

See also

Applies to

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>, String)

Registers a subscriber to the QueueItemAvailable event.

public:
 void RegisterForQueueItemAvailable(System::Workflow::ComponentModel::IActivityEventListener<System::Workflow::ComponentModel::QueueEventArgs ^> ^ eventListener, System::String ^ subscriberQualifiedName);
public void RegisterForQueueItemAvailable (System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.QueueEventArgs> eventListener, string subscriberQualifiedName);
member this.RegisterForQueueItemAvailable : System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.QueueEventArgs> * string -> unit
Public Sub RegisterForQueueItemAvailable (eventListener As IActivityEventListener(Of QueueEventArgs), subscriberQualifiedName As String)

Parameters

eventListener
IActivityEventListener<QueueEventArgs>

A subscriber for QueueEventArgs that implements the IActivityEventListener<T> interface.

subscriberQualifiedName
String

The QualifiedName of the activity that is subscribing to the QueueItemAvailable event or a null reference (Nothing in Visual Basic).

Exceptions

eventListener is a null reference (Nothing).

Remarks

If the qualified name of the subscribing activity is supplied by subscriberQualifiedName, it is returned in WorkflowQueueInfo.SubscribedActivityNames of WorkflowQueueInfo associated with this queue when WorkflowInstance.GetWorkflowQueueData is called.

Applies to