Method Run
Run(Func<Exception, bool>?, string?)
Runs a new Session creating a Toplevel and calling Begin(Toplevel). When the session is stopped, End(SessionToken) will be called.
[RequiresUnreferencedCode("AOT")]
[RequiresDynamicCode("AOT")]
[Obsolete("The legacy static Application object is going away.")]
public static Toplevel Run(Func<Exception, bool>? errorHandler = null, string? driverName = null)
Parameters
errorHandlerFunc<Exception, bool>Handler for any unhandled exceptions (resumes when returns true, rethrows when null).
driverNamestringThe 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
Remarks
Calling Init(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<TView>(Func<Exception, bool>?, string?)
Runs a new Session creating a Toplevel-derived object of type TView
and calling Run(Toplevel, Func<Exception, bool>?). When the session is stopped,
End(SessionToken) will be called.
[RequiresUnreferencedCode("AOT")]
[RequiresDynamicCode("AOT")]
[Obsolete("The legacy static Application object is going away.")]
public static TView Run<TView>(Func<Exception, bool>? errorHandler = null, string? driverName = null) where TView : Toplevel, new()
Parameters
errorHandlerFunc<Exception, bool>Handler for any unhandled exceptions (resumes when returns true, rethrows when null).
driverNamestringThe 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
- TView
The created
TViewobject. The caller is responsible for disposing this object.
Type Parameters
TViewThe type of Toplevel to create and run.
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(Toplevel, Func<Exception, bool>?) stop execution, call RequestStop() or RequestStop(Toplevel?).
Calling Run(Toplevel, Func<Exception, bool>?) is equivalent to calling Begin(Toplevel), followed by starting the main loop, and then calling End(SessionToken).
When using Run<TRunnable>(Func<Exception, bool>?) or Run(Func<Exception, bool>?, string?), Init(string?) will be called automatically.
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.
Shutdown() 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.
Run(Toplevel, Func<Exception, bool>?)
Runs a new Session using the provided Toplevel view and calling Run(Toplevel, Func<Exception, bool>?). When the session is stopped, End(SessionToken) will be called..
[Obsolete("The legacy static Application object is going away.")]
public static void Run(Toplevel view, Func<Exception, bool>? errorHandler = null)
Parameters
viewToplevelThe Toplevel to run as a modal.
errorHandlerFunc<Exception, bool>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 Run(Toplevel, Func<Exception, bool>?) stop execution, call RequestStop() or RequestStop(Toplevel?).
Calling Run(Toplevel, Func<Exception, bool>?) is equivalent to calling Begin(Toplevel), followed by starting the main loop, and then calling End(SessionToken).
When using Run<TRunnable>(Func<Exception, bool>?) or Run(Func<Exception, bool>?, string?), Init(string?) will be called automatically.
Shutdown() 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.