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