Method Run
Run(Func<Exception, bool>?, ConsoleDriver?)
Runs the application by creating a Toplevel object and calling Run(Toplevel, Func<Exception, bool>?).
public static Toplevel Run(Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null)
Parameters
errorHandler
Func<Exception, bool>driver
ConsoleDriver
Returns
Remarks
Calling Init(ConsoleDriver?, string?) first is not needed as this function will initialize the application.
Shutdown() must be called when the application is closing (typically after Run> has returned) to ensure resources are cleaned up and terminal settings restored.
The caller is responsible for disposing the object returned by this method.
Run<T>(Func<Exception, bool>?, ConsoleDriver?)
Runs the application by creating a Toplevel-derived object of type T
and calling
Run(Toplevel, Func<Exception, bool>?).
public static T Run<T>(Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null) where T : Toplevel, new()
Parameters
errorHandler
Func<Exception, bool>driver
ConsoleDriverThe ConsoleDriver to use. If not specified the default driver for the platform will be used ( WindowsDriver, CursesDriver, or NetDriver). Must be null if Init(ConsoleDriver?, string?) has already been called.
Returns
- T
The created T object. The caller is responsible for disposing this object.
Type Parameters
T
Remarks
Calling Init(ConsoleDriver?, string?) first is not needed as this function will initialize the application.
Shutdown() must be called when the application is closing (typically after Run> has returned) to ensure resources are cleaned up and terminal settings restored.
The caller is responsible for disposing the object returned by this method.
Run(Toplevel, Func<Exception, bool>?)
Runs the Application using the provided Toplevel view.
public static void Run(Toplevel view, Func<Exception, bool>? errorHandler = null)
Parameters
view
ToplevelThe Toplevel to run as a modal.
errorHandler
Func<Exception, bool>RELEASE builds only: Handler for any unhandled exceptions (resumes when returns true, rethrows when null).
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 a Run(Toplevel, Func<Exception, bool>?) stop execution, call RequestStop(Toplevel?).
Calling Run(Toplevel, Func<Exception, bool>?) is equivalent to calling Begin(Toplevel), followed by RunLoop(RunState), and then calling End(RunState).
Alternatively, to have a program control the main loop and process events manually, call Begin(Toplevel) to set things up manually and then repeatedly call RunLoop(RunState) with the wait parameter set to false. By doing this the RunLoop(RunState) method will only process any pending events, timers, idle handlers and then return control immediately.
When using Run<T>(Func<Exception, bool>?, ConsoleDriver?) or Run(Func<Exception, bool>?, ConsoleDriver?)Init(ConsoleDriver?, string?) will be called automatically.
RELEASE builds only: When errorHandler
is null any exceptions will be
rethrown. Otherwise, if errorHandler
will be called. If errorHandler
returns true the RunLoop(RunState) will resume; otherwise this method will
exit.