Table of Contents

Event SessionEnded

Namespace
Terminal.Gui.App
Assembly
Terminal.Gui.dll

Raised by End(SessionToken) after the runnable's state has fully unwound — including IsRunningChanged firing with false — and after End(SessionToken) has finished its state-unwinding work. The Runnable reference is null at this point. This event reports a token-lifecycle moment, not a state transition on the IRunnable.

event EventHandler<SessionTokenEventArgs>? SessionEnded

Returns

EventHandler<SessionTokenEventArgs>
Raised by after the runnable's state has fully unwound — including firing with false — and after has finished its state-unwinding work. The reference is null at this point. This event reports a token-lifecycle moment, not a state transition on the .

Remarks

At the moment SessionEnded fires, all state has already unwound: IsRunning is false and IsRunningChanged has already fired with false. To observe the runnable transitioning out of the running state, subscribe to IsRunningChanged instead.

The token's Runnable property is null at this point — it is cleared immediately before the event is raised. Subscribers that need the session result must read Result from the token; they must not attempt to access Runnable.

SessionEnded and SessionBegun are intentionally NOT a symmetric before/after pair. SessionBegun fires early — after the token has been pushed onto SessionStack but before the runnable's running/modal state has been published. SessionEnded fires late — after all state has unwound. This asymmetry is deliberate: the events mark token-lifecycle boundaries, not runnable-state transitions.

If StopAfterFirstIteration is true, callers to Begin(IRunnable) must also subscribe to SessionEnded and call End(SessionToken) themselves to complete the session.