Skip to main content

MarkdownStreamingSession Class

Definition​

Assembly:Avalonia.Controls.Markdown
Package:Avalonia.Controls.Markdown

Manages an active markdown streaming session. Text is appended via Avalonia.Controls.MarkdownStreamingSession.Append(string) and coalesced into periodic render updates at display refresh rate to avoid redundant work.

public class MarkdownStreamingSession

Inheritance: object -> MarkdownStreamingSession

Implements: IAsyncDisposable, IDisposable

Remarks​

Internally operates at the Avalonia.Controls.Documents.TextModel.TextDocument/Avalonia.Controls.Documents.TextModel.TextDocumentNode level to avoid temporary Avalonia.Controls.Documents.FlowDocument allocations and eager element materialization. Changed Markdig blocks are rendered to a single Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot, and the resulting node sub-trees are grafted directly into the live document tree with deferred element realization.

The parse, diff, and snapshot-build phases run on a background thread to keep the UI thread free for layout and input. Only the final tree-mutation step (apply delta) runs on the UI thread.

Methods​

NameDescription
Append (2 overloads)No summary available.
CompleteSignals that the LLM stream is finished. Performs a final parse and render pass, then cleans up resources.
CompleteAsyncAsync version of Avalonia.Controls.MarkdownStreamingSession.Complete that awaits the final layout pass.
DisposeNo summary available.
DisposeAsyncNo summary available.

Append overloads​

Append Method​

public void Append(ReadOnlyMemory<char> text)
Parameters​

text ReadOnlyMemory<char>

Append Method​

Appends a text chunk to the streaming buffer. Safe to call from any thread.

public void Append(string text)
Parameters​

text string

Complete Method​

Signals that the LLM stream is finished. Performs a final parse and render pass, then cleans up resources.

public void Complete()

CompleteAsync Method​

Async version of Avalonia.Controls.MarkdownStreamingSession.Complete that awaits the final layout pass.

public System.Threading.Tasks.ValueTask CompleteAsync()

Returns​

System.Threading.Tasks.ValueTask

Dispose Method​

public void Dispose()

DisposeAsync Method​

public System.Threading.Tasks.ValueTask DisposeAsync()

Returns​

System.Threading.Tasks.ValueTask

Properties​

NameDescription
IsCompletedGets whether the session has been completed.

IsCompleted Property​

Gets whether the session has been completed.

public bool IsCompleted { get; set; }

Events​

NameDescription
UpdatedRaised on the UI thread after each visible update is applied.

Updated Event​

Raised on the UI thread after each visible update is applied.

public event EventHandler Updated