Table of Contents

Method Run

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

Run(IRunnable, Func<Exception, bool>?)

Runs a new Session with the provided runnable view.

object? Run(IRunnable runnable, Func<Exception, bool>? errorHandler = null)

Parameters

runnable IRunnable

The runnable to execute.

errorHandler Func<Exception, bool>

Optional handler for unhandled exceptions (resumes when returns true, rethrows when null).

Returns

object

Remarks

This method is used to start processing events for the main application, but it is also used to run other modal views such as dialogs.

To make Run(IRunnable, Func<Exception, bool>?) stop execution, call RequestStop() or RequestStop(IRunnable?).

Calling Run(IRunnable, Func<Exception, bool>?) is equivalent to calling Begin(IRunnable), followed by starting the main loop, and then calling End(SessionToken).

In RELEASE builds: When errorHandler is null any exceptions will be rethrown. Otherwise, errorHandler will be called. If errorHandler returns true the main loop will resume; otherwise this method will exit.

Run<TRunnable>(Func<Exception, bool>?, string?)

Runs a new Session creating a IRunnable-derived object of type TRunnable and calling Run(IRunnable, Func<Exception, bool>?). When the session is stopped, End(SessionToken) will be called.

[RequiresUnreferencedCode("AOT")]
[RequiresDynamicCode("AOT")]
IApplication Run<TRunnable>(Func<Exception, bool>? errorHandler = null, string? driverName = null) where TRunnable : IRunnable, new()

Parameters

errorHandler Func<Exception, bool>

Handler for any unhandled exceptions (resumes when returns true, rethrows when null).

driverName string

The driver name. If not specified the default driver for the platform will be used. Must be null if Init(string?) has already been called.

Returns

IApplication

The created object. The caller is responsible for calling Dispose() on this object.

Type Parameters

TRunnable

Remarks

This method is used to start processing events for the main application, but it is also used to run other modal Views such as Dialog boxes.

To make Run(IRunnable, Func<Exception, bool>?) stop execution, call RequestStop() or RequestStop(IRunnable?).

In RELEASE builds: When errorHandler is null any exceptions will be rethrown. Otherwise, errorHandler will be called. If errorHandler returns true the main loop will resume; otherwise this method will exit.

Dispose() must be called when the application is closing (typically after Run has returned) to ensure resources are cleaned up and terminal settings restored.

In RELEASE builds: When errorHandler is null any exceptions will be rethrown. Otherwise, errorHandler will be called. If errorHandler returns true the main loop will resume; otherwise this method will exit.

The caller is responsible for disposing the object returned by this method.