IDocumentService.SubscribeAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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);
abstract member 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
.
Introduced in version DocumentService.