예제 #1
0
        public KeepAliveSession(RemoteHostClient client, RemoteHostClient.Connection connection, string serviceName, object callbackTarget)
        {
            _gate = new object();

            Initialize(client, connection);

            _remoteHostClientService = client.Workspace.Services.GetService <IRemoteHostClientService>();
            _serviceName             = serviceName;
            _callbackTarget          = callbackTarget;
        }
예제 #2
0
        public static async Task <SessionWithSolution> CreateAsync(RemoteHostClient.Connection connection, Solution solution, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(connection);
            Contract.ThrowIfNull(solution);

            PinnedRemotableDataScope scope = null;

            try
            {
                scope = await solution.GetPinnedScopeAsync(cancellationToken).ConfigureAwait(false);

                // set connection state for this session.
                // we might remove this in future. see https://github.com/dotnet/roslyn/issues/24836
                await connection.InvokeAsync(
                    WellKnownServiceHubServices.ServiceHubServiceBase_Initialize,
                    new object[] { scope.SolutionInfo },
                    cancellationToken).ConfigureAwait(false);

                return(new SessionWithSolution(connection, scope));
            }
            catch
            {
                // Make sure disposable objects are disposed when exceptions are thrown. The try/finally is used to
                // ensure 'scope' is disposed even if an exception is thrown while disposing 'connection'.
                try
                {
                    connection.Dispose();
                }
                finally
                {
                    scope?.Dispose();
                }

                // we only expect this to happen on cancellation. otherwise, rethrow
                cancellationToken.ThrowIfCancellationRequested();
                throw;
            }
        }
예제 #3
0
 private SessionWithSolution(RemoteHostClient.Connection connection, PinnedRemotableDataScope scope)
 {
     _connection = connection;
     _scope      = scope;
 }