private void OnErrorDataReceived(object sender, DataReceivedEventArgs e) { if (e.Data != null) { _log.WriteLineAsync(MessageCategory.Error, e.Data); } }
public async Task Run(CancellationToken ct = default(CancellationToken)) { TaskUtilities.AssertIsOnBackgroundThread(); if (_runTask != null) { throw new InvalidOperationException("This host is already running."); } ct = CancellationTokenSource.CreateLinkedTokenSource(ct, _cts.Token).Token; try { _runTask = RunWorker(ct); await _runTask; } catch (OperationCanceledException) when(ct.IsCancellationRequested) { // Expected cancellation, do not propagate, just exit process } catch (MessageTransportException ex) when(ct.IsCancellationRequested) { // Network errors during cancellation are expected, but should not be exposed to clients. throw new OperationCanceledException(new OperationCanceledException().Message, ex); } catch (Exception ex) { var message = "Exception in RHost run loop:\n" + ex; _log.WriteLineAsync(LogVerbosity.Minimal, MessageCategory.Error, message).DoNotWait(); Debug.Fail(message); throw; } finally { // Signal cancellation to any callbacks that haven't returned yet. _cts.Cancel(); _requests.Clear(); } }
public static void RHostProcessStarted(this IActionLog log, ProcessStartInfo psi) { var sb = new StringBuilder(); sb.AppendLine(Invariant($"R Host process started: {psi.FileName}")); if (psi.EnvironmentVariables.Count > 0) { sb.AppendLine("Environment variables:"); foreach (var variable in psi.Environment) { sb.Append(' ', 4).AppendLine(Invariant($"{variable.Key}={variable.Value}")); } } log.WriteLineAsync(MessageCategory.General, sb.ToString()); }
public static void RHostProcessExited(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, "R Host process exited"); }
public static void EnterRLoop(this IActionLog log, int depth) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, Invariant($"Enter R loop, depth={depth}")); }
public static void WatcherApplyRecoveryChange(this IActionLog log, string change) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, Invariant($"Apply recovery change: {change}")); }
public static void WatcherStarted(this IActionLog log) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, "MsBuildFileSystemWatcher started"); }
public static void ExitRLoop(this IActionLog log, int depth) { log.WriteLineAsync(MessageCategory.General, Invariant($"Exit R loop, depth={depth}")); }
public static void WatcherApplyChange(this IActionLog log, string change) { log.WriteLineAsync(MessageCategory.General, Invariant($"Apply change: {change}")); }
public static void WatcherConsumeChangesStarted(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, "File system changes consumer started"); }
public static void WatcherConsumeChangesScheduled(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, "Consume file system changes scheduled"); }
public static void WatcherStarting(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, "MsBuildFileSystemWatcher starting"); }
public static void WatcherApplyRecoveryChange(this IActionLog log, string change) { log.WriteLineAsync(MessageCategory.General, $"Apply recovery change: {change}"); }
public static void Request(this IActionLog log, string request, int depth) { log.WriteLineAsync(LogVerbosity.Traffic, MessageCategory.General, Invariant($"[Request,depth={depth}]:{request}")); }
public static void ConnectedToRHostWebSocket(this IActionLog log, string uri, int attempt) { log.WriteLineAsync(MessageCategory.General, Invariant($"Connected to R Web Host socket at {uri} on attempt #{attempt}")); }
public static void FailedToConnectToRHost(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, Invariant($"Timed out waiting for RHost to connect")); }
public static void WatcherApplyChangeFailed(this IActionLog log, string change, Exception exception) { log.WriteLineAsync(MessageCategory.Error, Invariant($"Failed to apply change '{change}':{exception}")); }
public static void Response(this IActionLog log, string response, int depth) { log.WriteLineAsync(MessageCategory.General, Invariant($"[Response,depth={depth}]:{response}")); }
public static void MsBuildAfterChangesApplied(this IActionLog log, ProjectRootElement rootElement) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, "File mirroring project after changes applied:" + Environment.NewLine + rootElement.RawXml); }
public static void WatcherConsumeChangesFinished(this IActionLog log) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, "File system changes consumer finished"); }
public static void ApplyProjectChangesStarted(this IActionLog log) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, "Starting applying changes to file-mirroring project"); }
public static void WatcherApplyRecoveryChangeFailed(this IActionLog log, string change, Exception exception) { log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.Error, Invariant($"Failed to apply recovery change '{change}', closing watcher:{exception}")); }
public static void ApplyProjectChangesFinished(this IActionLog log) { log.WriteLineAsync(MessageCategory.General, "Finished applying changes to file-mirroring project"); }