Ejemplo n.º 1
0
 private void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (e.Data != null)
     {
         _log.WriteLineAsync(MessageCategory.Error, e.Data);
     }
 }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 public static void RHostProcessExited(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, "R Host process exited");
 }
Ejemplo n.º 5
0
 public static void EnterRLoop(this IActionLog log, int depth)
 {
     log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, Invariant($"Enter R loop, depth={depth}"));
 }
Ejemplo n.º 6
0
 public static void WatcherApplyRecoveryChange(this IActionLog log, string change)
 {
     log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, Invariant($"Apply recovery change: {change}"));
 }
Ejemplo n.º 7
0
 public static void WatcherStarted(this IActionLog log)
 {
     log.WriteLineAsync(LogVerbosity.Normal, MessageCategory.General, "MsBuildFileSystemWatcher started");
 }
Ejemplo n.º 8
0
 public static void ExitRLoop(this IActionLog log, int depth)
 {
     log.WriteLineAsync(MessageCategory.General, Invariant($"Exit R loop, depth={depth}"));
 }
Ejemplo n.º 9
0
 public static void WatcherApplyChange(this IActionLog log, string change)
 {
     log.WriteLineAsync(MessageCategory.General, Invariant($"Apply change: {change}"));
 }
Ejemplo n.º 10
0
 public static void WatcherConsumeChangesStarted(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, "File system changes consumer started");
 }
Ejemplo n.º 11
0
 public static void WatcherConsumeChangesScheduled(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, "Consume file system changes scheduled");
 }
Ejemplo n.º 12
0
 public static void WatcherStarting(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, "MsBuildFileSystemWatcher starting");
 }
Ejemplo n.º 13
0
 public static void WatcherApplyRecoveryChange(this IActionLog log, string change)
 {
     log.WriteLineAsync(MessageCategory.General, $"Apply recovery change: {change}");
 }
Ejemplo n.º 14
0
 public static void Request(this IActionLog log, string request, int depth)
 {
     log.WriteLineAsync(LogVerbosity.Traffic, MessageCategory.General, Invariant($"[Request,depth={depth}]:{request}"));
 }
Ejemplo n.º 15
0
 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}"));
 }
Ejemplo n.º 16
0
 public static void FailedToConnectToRHost(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, Invariant($"Timed out waiting for RHost to connect"));
 }
Ejemplo n.º 17
0
 public static void WatcherApplyChangeFailed(this IActionLog log, string change, Exception exception)
 {
     log.WriteLineAsync(MessageCategory.Error, Invariant($"Failed to apply change '{change}':{exception}"));
 }
Ejemplo n.º 18
0
 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);
 }
Ejemplo n.º 20
0
 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");
 }
Ejemplo n.º 22
0
 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}"));
 }
Ejemplo n.º 23
0
 public static void ApplyProjectChangesFinished(this IActionLog log)
 {
     log.WriteLineAsync(MessageCategory.General, "Finished applying changes to file-mirroring project");
 }