WorkflowQueue.RegisterForQueueItemAvailable 方法

定义

QueueItemAvailable 事件注册一个订户。Registers a subscriber to the QueueItemAvailable event.

重载

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>)

QueueItemAvailable 事件注册一个订户。Registers a subscriber to the QueueItemAvailable event.

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>, String)

QueueItemAvailable 事件注册一个订户。Registers a subscriber to the QueueItemAvailable event.

注解

您可以使用重载的 RegisterForQueueItemAvailable 方法为 QueueItemAvailable 事件注册一个订户。You can use the overloaded RegisterForQueueItemAvailable methods to register a subscriber for the QueueItemAvailable event. QueueItemAvailable 事件用于通知订户项已经传送(以异步方式)至此 WorkflowQueueThe QueueItemAvailable event is used to notify subscribers that an item has been delivered (in an asynchronous manner) to this WorkflowQueue.

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>)

QueueItemAvailable 事件注册一个订户。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))

参数

eventListener
IActivityEventListener<QueueEventArgs>

实现 QueueEventArgs 接口的 IActivityEventListener<T> 的订户。A subscriber for QueueEventArgs that implements the IActivityEventListener<T> interface.

例外

eventListener 为空引用(在 Visual Basic 中为 Nothing)。eventListener is a null reference (Nothing in Visual Basic).

示例

下面的代码示例演示如何通过调用 WorkflowQueue 方法创建 WorkflowQueuingService.GetWorkflowQueueThe following code example demonstrates how you can create a WorkflowQueue by calling the WorkflowQueuingService.GetWorkflowQueue method. 它还使用 RegisterForQueueItemAvailable 注册指定的侦听器。It also uses the RegisterForQueueItemAvailable to register the specified listener.

此代码示例摘自 FileSystemEvent.cs 文件的“文件观察程序活动”SDK 示例。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

适用于

RegisterForQueueItemAvailable(IActivityEventListener<QueueEventArgs>, String)

QueueItemAvailable 事件注册一个订户。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)

参数

eventListener
IActivityEventListener<QueueEventArgs>

实现 QueueEventArgs 接口的 IActivityEventListener<T> 的订户。A subscriber for QueueEventArgs that implements the IActivityEventListener<T> interface.

subscriberQualifiedName
String

订阅 事件的活动的 或空引用(在 Visual Basic 中为 )。The QualifiedName of the activity that is subscribing to the QueueItemAvailable event or a null reference (Nothing in Visual Basic).

例外

eventListener 为空引用 (Nothing)。eventListener is a null reference (Nothing).

注解

如果订阅活动的限定名称由 提供,则当调用 时,它将在与此队列关联的 的 中返回。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.

适用于