Compartir a través de


DocumentsExtensibility.SubscribeAsync Method

Definition

Adds a listener for document events.

public System.Threading.Tasks.Task<IDisposable> SubscribeAsync (Microsoft.VisualStudio.RpcContracts.Documents.IDocumentEventsListener listener, string? filterRegex, System.Threading.CancellationToken token);
member this.SubscribeAsync : Microsoft.VisualStudio.RpcContracts.Documents.IDocumentEventsListener * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<IDisposable>
Public Function SubscribeAsync (listener As IDocumentEventsListener, filterRegex As String, token As CancellationToken) As Task(Of IDisposable)

Parameters

listener
IDocumentEventsListener

The event listener.

filterRegex
String

An optional regular expression string used to filter events. If this string is not null and not empty, then events will only be raised for documents whose monikers match the regular expression.

token
CancellationToken

The cancellation token.

Returns

A Task representing the asynchronous operation. The result of the task is an object which, when disposed, will remove the event listener.

Remarks

Before the asynchronous operation completes, the listener will receive an OpenedAsync(DocumentEventArgs, CancellationToken) event for each open document whose moniker matches filterRegex.

Applies to