/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/WorkspaceChangeWatcher.vb
40 строк
2 KB
Todd Grunke
Start moving workspace events to fire on background threads (#78134)
26 апр 2025, 17:20
Не верифицирован
26 апр 2025, 17:20
0a6e36a
Код
Авторство
О чём код?
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Shared.TestHooks Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework Friend Class WorkspaceChangeWatcher Implements IDisposable Private ReadOnly _asynchronousOperationWaiter As IAsynchronousOperationWaiter Private ReadOnly _workspaceChangedDisposer As WorkspaceEventRegistration Private _changeEvents As New List(Of WorkspaceChangeEventArgs) Public Sub New(environment As TestEnvironment) Dim listenerProvider = environment.ExportProvider.GetExportedValue(Of AsynchronousOperationListenerProvider)() _asynchronousOperationWaiter = listenerProvider.GetWaiter(FeatureAttribute.Workspace) _workspaceChangedDisposer = environment.Workspace.RegisterWorkspaceChangedHandler(AddressOf OnWorkspaceChanged) End Sub Public Sub Dispose() Implements IDisposable.Dispose _workspaceChangedDisposer.Dispose() End Sub Private Sub OnWorkspaceChanged(e As WorkspaceChangeEventArgs) _changeEvents.Add(e) End Sub Friend Async Function GetNewChangeEventsAsync() As Task(Of IEnumerable(Of WorkspaceChangeEventArgs)) Await _asynchronousOperationWaiter.ExpeditedWaitAsync() ' Return the events so far, clearing the list if somebody wants to ask for further events Dim changeEvents = _changeEvents _changeEvents = New List(Of WorkspaceChangeEventArgs)() Return changeEvents End Function End Class End Namespace