Table of Contents

Class RunCancellation

Namespace
Valheim.Testing.GameSessions
Assembly
Valheim.Testing.GameSessions.dll

Cancels a console-owned setup or run on Ctrl+C or SIGTERM. Dispose after cleanup so another run in the same process does not inherit the handler. Cleanup never runs on the cancelled token: BeginCleanup(TimeSpan?) gives it a fresh one, bounded by a budget, which only a further signal during cleanup (the escape from a cleanup that hangs) or the budget itself cancels; Abandoned then says why, and the run is left for valheim-test env recover. Nothing is ever killed by the escape itself.

public sealed class RunCancellation
Inheritance
object
RunCancellation

Constructors

RunCancellation()

public RunCancellation()

Fields

CleanupBudget

How long cleanup may take once it begins, unless another signal ends it sooner.

public static readonly TimeSpan CleanupBudget

Field Value

TimeSpan

Properties

Abandoned

Why cleanup was abandoned (a second signal, or its budget), or null while it was not.

public string? Abandoned { get; }

Property Value

string

Token

The token to pass through preparation, launch and event waits.

public CancellationToken Token { get; }

Property Value

CancellationToken

Methods

BeginCleanup(TimeSpan?)

The token cleanup runs on, from now: never the run's (cancelled) token. A signal after cleanup began, when at least one came before it (a second Ctrl+C), or the end of budget (CleanupBudget by default) cancels it. Calling it again returns the same token.

public CancellationToken BeginCleanup(TimeSpan? budget = null)

Parameters

budget TimeSpan?

Returns

CancellationToken

Cancel()

Cancels the run from code, as Ctrl+C would.

public void Cancel()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()