Table of Contents

Method EnsureStartedAsync

Namespace
Qavren.Edge.Hosting
Assembly
Qavren.Edge.Core.dll

EnsureStartedAsync(CancellationToken)

Calls Start() if needed, awaits Started, and rethrows its fault. From inside an IEdgeStartupTask it returns at once instead of waiting on the task that called it: the tasks ordered before the caller have completed, the ones after it have not.

public ValueTask EnsureStartedAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask

Remarks

Called from inside a startup task, this returns at once. Every Qavren.Edge entry point awaits startup first - IEdgeDatabase.OpenConnectionAsync, a session acquire, a chat turn - and startup completes only when every task has returned. A task that opened a connection to seed a table, which is what a startup task is for, therefore waited on itself and the host never started. What such a task can rely on is exactly what the order promises: every task ordered before it has completed. Tasks ordered after it have not run.

The exemption follows the task's own call path and ends when the task returns. Work a task starts and does not await goes back to waiting for startup like any other caller.