static void OnCodeCellEvent(ICodeCellEvent codeCellEvent) { // NOTE: events may post to cells "out of order" from evaluation in // special cases such as reactive/IObservable integrations. This is // not handled at all in this simple console client since we just // append to stdout. Because of this, ignore "out of order" cell // events entirely. A real UI would render them in the correct place. if (lastCodeCellId != default && codeCellEvent.CodeCellId != lastCodeCellId) { return; } switch (codeCellEvent) { // a full UI would set cell state to show a spinner and // enable a button to abort the running evaluation here case CodeCellEvaluationStartedEvent _: break; // and would then hide the spinner and button here case CodeCellEvaluationFinishedEvent finishedEvent: lastCellEvaluationStatus = finishedEvent.Status; switch (finishedEvent.Status) { case CodeCellEvaluationStatus.Disconnected: RenderError("Agent was disconnected while evaluating cell"); break; case CodeCellEvaluationStatus.Interrupted: RenderError("Evaluation was aborted"); break; case CodeCellEvaluationStatus.EvaluationException: RenderError("An exception was thrown while evaluating cell"); break; } foreach (var diagnostic in finishedEvent.Diagnostics) { RenderDiagnostic(diagnostic); } break; // and would render console output and results on the cell itself // instead of just appending to the screen (see "out of order" note) case CapturedOutputSegment output: RenderOutput(output); break; case CodeCellResultEvent result: RenderResult(result); break; } }
public CodeCellEvaluationFinishedEvent( CodeCellId codeCellId, CodeCellEvaluationStatus status, bool shouldStartNewCell, IReadOnlyList <Diagnostic> diagnostics) { CodeCellId = codeCellId; Status = status; ShouldStartNewCell = shouldStartNewCell; Diagnostics = diagnostics; }
public CodeCellEvaluationFinishedEvent(CodeCellId codeCellId, CodeCellEvaluationStatus status, bool shouldStartNewCell, IReadOnlyList <Diagnostic> diagnostics);