IRunicModelContext interface

Namespace Runic.Navigation · Runic.Navigation 0.7.0-preview.5

public interface IRunicModelContext : IAsyncDisposable

Inherits or implements IAsyncDisposable.

Owns short, serialized mutations and reads for one mutable application-model graph.

Remarks

A turn is deliberately synchronous. Do asynchronous I/O and interactions outside a turn, then use a new turn to commit their result. A presentation lease never owns this context; the composition root or an explicit context lease does.

Generated bridges and content sessions serve synchronous transport routes. They run work inline when IRunicModelContext.IsExecuting is true and otherwise block the calling thread until IRunicModelContext.InvokeAsync completes. An implementation must therefore report true for code running inside one of its turns, and a turn must not need a blocked caller's thread to make progress.

Properties

IsExecuting

bool IsExecuting { get; }

Gets whether the calling code is executing one of this context's turns.

Methods

InvokeAsync

ValueTask InvokeAsync(Action turn, CancellationToken cancellationToken = default)

Runs a short synchronous turn in this context.

InvokeAsync

ValueTask<T> InvokeAsync<T>(Func<T> turn, CancellationToken cancellationToken = default)

Runs a short synchronous turn in this context and returns its result.

TryPost

bool TryPost(Action turn)

Queues a short synchronous turn when the context is still accepting work.

Events

UnhandledTurnException

event Action<Exception>? UnhandledTurnException

Receives exceptions thrown by turns queued with IRunicModelContext.TryPost, and an ObjectDisposedException for each posted turn dropped by disposal.