private async Task <RemoteHostClient.Session> TryGetSessionAsync() { using (await _gate.DisposableWaitAsync(_cancellationToken).ConfigureAwait(false)) { if (_sessionDoNotAccessDirectly != null) { return(_sessionDoNotAccessDirectly); } if (_client == null) { // client can be null if host is shutting down return(null); } // We create a single session and use it for the entire lifetime of this process. // That single session will be used to do all communication with the remote process. // This is because each session will cause a new instance of the RemoteSymbolSearchUpdateEngine // to be created on the remote side. We only want one instance of that type. The // alternative is to make that type static variable on the remote side. But that's // much less clean and would make some of the state management much more complex. _sessionDoNotAccessDirectly = await _client.TryCreateServiceSessionAsync( WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine, _logService, _cancellationToken).ConfigureAwait(false); return(_sessionDoNotAccessDirectly); } }
private async void OnConnectionChanged(object sender, bool connected) { if (connected) { return; } // to make things simpler, this is not cancellable. I believe this // is okay since this handle rare cases where remote host is recycled or // removed using (await _gate.DisposableWaitAsync(CancellationToken.None).ConfigureAwait(false)) { _client.ConnectionChanged -= OnConnectionChanged; _sessionDoNotAccessDirectly?.Dispose(); _sessionDoNotAccessDirectly = null; _client = await _workspace.TryGetRemoteHostClientAsync(CancellationToken.None).ConfigureAwait(false); if (_client != null) { // client can be null if host is shutting down _client.ConnectionChanged += OnConnectionChanged; } } }
private async Task <ImmutableArray <INavigateToSearchResult> > SearchProjectInRemoteProcessAsync( RemoteHostClient.Session session, Project project, string searchPattern, CancellationToken cancellationToken) { var serializableResults = await session.InvokeAsync <ImmutableArray <SerializableNavigateToSearchResult> >( nameof(IRemoteNavigateToSearchService.SearchProjectAsync), new object[] { project.Id, searchPattern }, cancellationToken).ConfigureAwait(false); return(serializableResults.SelectAsArray(r => r.Rehydrate(project.Solution))); }
private async Task <ImmutableArray <AddImportFixData> > GetFixesInRemoteProcessAsync( RemoteHostClient.Session session, Document document, TextSpan span, string diagnosticId, bool searchReferenceAssemblies, ImmutableArray <PackageSource> packageSources) { var result = await session.InvokeAsync <ImmutableArray <AddImportFixData> >( nameof(IRemoteAddImportFeatureService.GetFixesAsync), new object[] { document.Id, span, diagnosticId, searchReferenceAssemblies, packageSources }).ConfigureAwait(false); return(result); }
public RemoteUpdateEngine(RemoteHostClient.Session session) { _session = session; }
internal Session(RemoteHostClient.Session inner) { _inner = inner; }