public VsRHostScript(IRSessionCallback clientApp = null) : base( VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>(), VsAppShell.Current.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate().BrokerConnector, clientApp) { }
public async Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000) { _disposeToken.ThrowIfDisposed(); var lockToken = await _initializationLock.WaitAsync(); if (!lockToken.IsSet) { await StartHostAsyncBackground(startupInfo, callback, lockToken, timeout); } }
public async Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000) { _disposeToken.ThrowIfDisposed(); if (Interlocked.CompareExchange(ref _initializationTcs, new TaskCompletionSourceEx <object>(), null) != null) { throw new InvalidOperationException("Another instance of RHost is running for this RSession. Stop it before starting new one."); } await StartHostAsyncBackground(startupInfo, callback, timeout); }
public async Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000, CancellationToken cancellationToken = default(CancellationToken)) { using (_disposeToken.Link(ref cancellationToken)) { var lockToken = await _initializationLock.WaitAsync(cancellationToken); if (!lockToken.IsSet) { await StartHostAsyncBackground(startupInfo, callback, lockToken, timeout, cancellationToken); } } }
public async Task InitializeAsync(IRSessionCallback clientApp = null) { _clientApp = clientApp ?? _clientApp; Session = SessionProvider.GetOrCreate(SessionNames.InteractiveWindow); if (Session.IsHostRunning) { await Session.StopHostAsync(); } await Session.StartHostAsync(new RHostStartupInfo(), _clientApp ?? new RHostClientTestApp(), 50000); }
public async Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000) { var existingInitializationTcs = Interlocked.CompareExchange(ref _initializationTcs, new TaskCompletionSource <object>(), null); if (existingInitializationTcs == null) { await StartHostAsyncBackground(startupInfo, callback, timeout); } else { await existingInitializationTcs.Task; } }
public async Task InitializeAsync(IRSessionCallback clientApp = null) { _clientApp = clientApp; await Workflow.RSessions.TrySwitchBrokerAsync(GetType().Name); if (Workflow.RSession.IsHostRunning) { await Workflow.RSession.StopHostAsync(); } await Workflow.RSession.StartHostAsync(new RHostStartupInfo(), _clientApp ?? new RHostClientTestApp(), 50000); }
public async Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000, CancellationToken cancellationToken = default(CancellationToken)) { using (_disposeToken.Link(ref cancellationToken)) { var isStartedTask = _initializationLock.WaitAsync(cancellationToken); if (isStartedTask.IsCompleted && !isStartedTask.Result.IsSet) { var lockToken = isStartedTask.Result; await StartHostAsyncBackground(startupInfo, callback, lockToken, timeout, cancellationToken); } else { throw new InvalidOperationException("Another instance of RHost is running for this RSession. Stop it before starting new one."); } } }
public async Task InitializeAsync(IRSessionCallback clientApp = null) { _clientApp = clientApp ?? _clientApp; Session = SessionProvider.GetOrCreate(SessionGuids.InteractiveWindowRSessionGuid); if (Session.IsHostRunning) { await Session.StopHostAsync(); } await Session.StartHostAsync(new RHostStartupInfo { Name = "RHostScript", CranMirrorName = RToolsSettings.Current.CranMirror, CodePage = RToolsSettings.Current.RCodePage, RHostCommandLineArguments = RToolsSettings.Current.LastActiveConnection.RCommandLineArguments }, _clientApp ?? new RHostClientTestApp(), 50000); }
public RHostScript(IRSessionProvider sessionProvider, IRSessionCallback clientApp = null) { SessionProvider = sessionProvider; Session = SessionProvider.GetOrCreate(GuidList.InteractiveWindowRSessionGuid); Session.IsHostRunning.Should().BeFalse(); Session.StartHostAsync(new RHostStartupInfo { Name = "RHostScript", RBasePath = RToolsSettings.Current.RBasePath, RHostCommandLineArguments = RToolsSettings.Current.RCommandLineArguments, CranMirrorName = RToolsSettings.Current.CranMirror, CodePage = RToolsSettings.Current.RCodePage }, clientApp ?? new RHostClientTestApp(), 50000).Wait(); }
private async Task StartHostAsyncBackground(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout) { await TaskUtilities.SwitchToBackgroundThread(); _callback = callback; _startupInfo = startupInfo; ClearPendingRequests(new RHostDisconnectedException()); ScheduleAfterHostStarted(startupInfo); var initializationTask = _initializationTcs.Task; _hostRunTask = CreateAndRunHost(startupInfo, timeout); await initializationTask; }
private async Task StartHostAsyncBackground(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout) { await TaskUtilities.SwitchToBackgroundThread(); _callback = callback; _host = new RHost(startupInfo != null ? startupInfo.Name : "Empty", this); ClearPendingRequests(); var initializationTask = _initializationTcs.Task; _hostRunTask = CreateAndRunHost(startupInfo, timeout); ScheduleAfterHostStarted(startupInfo); await initializationTask; }
public RHostScript(IRSessionProvider sessionProvider, IRSessionCallback clientApp = null) { SessionProvider = sessionProvider; Session = SessionProvider.GetOrCreate(GuidList.InteractiveWindowRSessionGuid); if (Session.IsHostRunning) { Session.StopHostAsync().Wait(); } Session.StartHostAsync(new RHostStartupInfo { Name = "RHostScript", CranMirrorName = RToolsSettings.Current.CranMirror, CodePage = RToolsSettings.Current.RCodePage, RHostCommandLineArguments = RToolsSettings.Current.LastActiveConnection.RCommandLineArguments }, clientApp ?? new RHostClientTestApp(), 50000).Wait(); }
private async Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout, bool throwIfStarted, CancellationToken cancellationToken) { using (_disposeToken.Link(ref cancellationToken)) { await TaskUtilities.SwitchToBackgroundThread(); using (await _initializationLock.WaitAsync(cancellationToken)) { if (_hostStartedTcs.Task.Status != TaskStatus.RanToCompletion || !_isHostRunning) { await StartHostAsyncBackground(startupInfo, callback, timeout, cancellationToken); } else if (throwIfStarted) { throw new InvalidOperationException("Another instance of RHost is running for this RSession. Stop it before starting new one."); } } } }
private async Task ExecuteInSession(string[] inputs, IRSessionCallback app) { using (var sessionProvider = new RSessionProvider(_services)) { await sessionProvider.TrySwitchBrokerAsync(nameof(IdeGraphicsDeviceTest)); var session = sessionProvider.GetOrCreate(_testMethod.FileSystemSafeName); await session.StartHostAsync(new RHostStartupInfo(), app, 50000); foreach (var input in inputs) { using (var interaction = await session.BeginInteractionAsync()) { await interaction.RespondAsync(input.EnsureLineBreak()); } } await session.StopHostAsync(); } }
private async Task ExecuteInSession(string[] inputs, IRSessionCallback app) { using (var sessionProvider = new RSessionProvider()) { var session = sessionProvider.GetOrCreate(Guid.NewGuid(), _brokerConnector); await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, app, 50000); foreach (var input in inputs) { using (var interaction = await session.BeginInteractionAsync()) { await interaction.RespondAsync(input + "\n"); } } await session.StopHostAsync(); } }
private async Task StartHostAsyncBackground(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout, CancellationToken cancellationToken) { TaskUtilities.AssertIsOnBackgroundThread(); _callback = callback; _startupInfo = startupInfo ?? new RHostStartupInfo(); RHost host; try { var connectionInfo = new HostConnectionInfo(Name, this, _startupInfo.UseRHostCommandLineArguments, timeout); host = await BrokerClient.ConnectAsync(connectionInfo, cancellationToken); } catch (OperationCanceledException ex) { _hostStartedTcs.TrySetCanceled(ex); throw; } catch (Exception ex) { _hostStartedTcs.TrySetException(ex); throw; } await StartHostAsyncBackground(host, cancellationToken); }
private async Task StartHostAsyncBackground(RHostStartupInfo startupInfo, IRSessionCallback callback, IBinaryAsyncLockToken lockToken, int timeout) { await TaskUtilities.SwitchToBackgroundThread(); _callback = callback; _startupInfo = startupInfo; RHost host; try { host = await BrokerClient.ConnectAsync(startupInfo.Name, this, startupInfo.RHostCommandLineArguments, timeout); } catch (OperationCanceledException ex) { _initializationTcs.TrySetCanceled(ex); lockToken.Reset(); throw; } catch (Exception ex) { _initializationTcs.TrySetException(ex); lockToken.Reset(); throw; } await StartHostAsyncBackground(host, lockToken); }
public VsRHostScript(IRSessionProvider sessionProvider, bool async, IRSessionCallback clientApp) : base(sessionProvider, async, clientApp) { }
public Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, IUIService ui, int timeout = 3000, CancellationToken cancellationToken = default) => StartHostAsync(startupInfo, callback, ui, timeout, false, cancellationToken);
public RHostScript(IExportProvider exportProvider, IRHostBrokerConnector brokerConnector, IRSessionCallback clientApp = null) : this(exportProvider.GetExportedValue <IRSessionProvider>(), brokerConnector, clientApp) { }
public Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000, CancellationToken cancellationToken = default(CancellationToken)) { IsHostRunning = true; Connected?.Invoke(this, new RConnectedEventArgs(string.Empty)); return Task.CompletedTask; }
public HostBasedInteractiveTest(IRHostBrokerConnector brokerConnector, IRSessionCallback callback = null) { HostScript = new VsRHostScript(SessionProvider, brokerConnector, callback); }
public Task EnsureHostStartedAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000) { IsHostRunning = true; Connected?.Invoke(this, new RConnectedEventArgs(string.Empty)); return(Task.CompletedTask); }
public RHostScript(IExportProvider exportProvider, IRSessionCallback clientApp = null) : this(exportProvider.GetExportedValue <IRSessionProvider>(), exportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate().BrokerConnector, clientApp) { }
public RHostScript(IRSessionProvider sessionProvider, bool async, IRSessionCallback clientApp) { SessionProvider = sessionProvider; _clientApp = clientApp; }
public RHostScript(IRSessionProvider sessionProvider, IRSessionCallback clientApp = null) { SessionProvider = sessionProvider; _clientApp = clientApp; InitializeAsync().Wait(); }
public Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000, CancellationToken cancellationToken = default(CancellationToken)) { IsHostRunning = true; Connected?.Invoke(this, new RConnectedEventArgs(string.Empty)); return(Task.CompletedTask); }
public VsRHostScript(IServiceContainer services, IRSessionCallback clientApp = null) : base(services, clientApp) { }
public Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000) { IsHostRunning = true; Connected?.Invoke(this, EventArgs.Empty); return(Task.CompletedTask); }
public VsRHostScript(IRSessionProvider sessionProvider, IRSessionCallback clientApp = null) : base(sessionProvider, clientApp) { }
private async Task ExecuteInSession(string[] inputs, IRSessionCallback app) { using (var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal())) { await sessionProvider.TrySwitchBrokerAsync(nameof(IdeGraphicsDeviceTest)); var session = sessionProvider.GetOrCreate(Guid.NewGuid()); await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, app, 50000); foreach (var input in inputs) { using (var interaction = await session.BeginInteractionAsync()) { await interaction.RespondAsync(input.EnsureLineBreak()); } } await session.StopHostAsync(); } }
public Task StartHostAsync(RHostStartupInfo startupInfo, IRSessionCallback callback, int timeout = 3000, CancellationToken cancellationToken = default(CancellationToken)) => StartHostAsync(startupInfo, callback, timeout, true, cancellationToken);
public HostBasedInteractiveTest(IRSessionCallback callback = null) { HostScript = new VsRHostScript(SessionProvider, callback); }
public HostBasedInteractiveTest(bool async, IRSessionCallback callback = null) { HostScript = new VsRHostScript(SessionProvider, async, callback); }
public VsRHostScript(IRSessionProvider sessionProvider, IRHostBrokerConnector brokerConnector, IRSessionCallback clientApp = null) : base(sessionProvider, brokerConnector, clientApp) { }