Пример #1
0
        public static async Task <SessionWithSolution> CreateAsync(KeepAliveSession keepAliveSession, Solution solution, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(keepAliveSession);
            Contract.ThrowIfNull(solution);

            var service = solution.Workspace.Services.GetRequiredService <IRemotableDataService>();
            var scope   = await service.CreatePinnedRemotableDataScopeAsync(solution, cancellationToken).ConfigureAwait(false);

            SessionWithSolution?session = null;

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

                // transfer ownership of connection and scope to the session object:
                session = new SessionWithSolution(keepAliveSession, scope);
            }
            finally
            {
                if (session == null)
                {
                    scope.Dispose();
                }
            }

            return(session);
        }
Пример #2
0
 private SessionWithSolution(KeepAliveSession keepAliveSession, PinnedRemotableDataScope scope)
 {
     KeepAliveSession = keepAliveSession;
     _scope           = scope;
 }