Esempio n. 1
0
        public static async Task DisposeAsync(this IPackageIndex packageIndex, IExportProvider exportProvider)
        {
            IRSessionProvider sessionProvider = exportProvider.GetExportedValue <IRSessionProvider>();

            if (sessionProvider != null)
            {
                await Task.WhenAll(sessionProvider.GetSessions().Select(s => s.StopHostAsync()));
            }
            packageIndex?.Dispose();
        }
Esempio n. 2
0
        public static async Task DisposeAsync()
        {
            IRSessionProvider sessionProvider = EditorShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>();

            if (sessionProvider != null)
            {
                await Task.WhenAll(sessionProvider.GetSessions().Select(s => s.StopHostAsync()));
            }

            FunctionIndex.Terminate();
        }
        private async Task SetSessionCodePage()
        {
            IRSessionProvider sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>();
            var sessions = sessionProvider.GetSessions();
            var cp       = RToolsSettings.Current.RCodePage;

            foreach (var s in sessions.Where(s => s.IsHostRunning))
            {
                try {
                    using (var eval = await s.BeginEvaluationAsync()) {
                        await eval.SetCodePageAsync(cp);
                    }
                } catch (OperationCanceledException) { }
            }
        }
        private async Task SetMirrorToSession()
        {
            IRSessionProvider sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>();
            var    sessions   = sessionProvider.GetSessions();
            string mirrorName = RToolsSettings.Current.CranMirror;
            string mirrorUrl  = CranMirrorList.UrlFromName(mirrorName);

            foreach (var s in sessions.Where(s => s.IsHostRunning))
            {
                try {
                    using (var eval = await s.BeginEvaluationAsync()) {
                        await eval.SetVsCranSelection(mirrorUrl);
                    }
                } catch (OperationCanceledException) { }
            }
        }
Esempio n. 5
0
        public async Task ConnectAsync(IConnection connection)
        {
            var sessions = _sessionProvider.GetSessions().ToList();

            if (sessions.Any())
            {
                await Task.WhenAll(sessions.Select(s => s.StopHostAsync()));
            }

            if (ActiveConnection != null && ActiveConnection.Id != connection.Id)
            {
                SwitchBroker(connection);
            }

            if (sessions.Any())
            {
                await Task.WhenAll(sessions.Select(s => s.RestartHostAsync()));
            }
        }