public void StartListening(Workspace workspace, IDiagnosticService diagnosticService) { var errorList = _threadingContext.JoinableTaskFactory.Run( async() => { await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); return(await _asyncServiceProvider .GetServiceAsync(typeof(SVsErrorList)) .ConfigureAwait(true) as IErrorList); } ); if (errorList == null) { // nothing to do when there is no error list. // it can happen if VS ran in command line mode return; } var table = new VisualStudioDiagnosticListTable( (VisualStudioWorkspaceImpl)workspace, diagnosticService, _tableManagerProvider, errorList ); }
public void StartListening(Workspace workspace, IDiagnosticService diagnosticService) { _threadingContext.RunWithShutdownBlockAsync(async cancellationToken => { using var asyncToken = _asynchronousOperationListener.BeginAsyncOperation(nameof(VisualStudioDiagnosticListTableWorkspaceEventListener) + "." + nameof(StartListening)); await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var errorList = (await _asyncServiceProvider.GetServiceAsync(typeof(SVsErrorList)).ConfigureAwait(true)) as IErrorList; if (errorList == null) { // nothing to do when there is no error list. // it can happen if VS ran in command line mode return; } var table = new VisualStudioDiagnosticListTable( (VisualStudioWorkspaceImpl)workspace, _threadingContext, diagnosticService, _tableManagerProvider, errorList); }); }