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")]
public 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")]
public 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..
public 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.
Run(IRunnable, Func<Exception, bool>?)
Runs a new Session with the provided runnable view.
public void Run(IRunnable runnable, Func<Exception, bool>? errorHandler = null)
Parameters
runnableIRunnableThe runnable to execute.
errorHandlerFunc<Exception, bool>Optional handler for 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 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(RunnableSessionToken).
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>?)
Creates and runs a new session with a TRunnable of the specified type.
public IApplication Run<TRunnable>(Func<Exception, bool>? errorHandler = null) where TRunnable : IRunnable, new()
Parameters
errorHandlerFunc<Exception, bool>Optional handler for unhandled exceptions (resumes when returns true, rethrows when null).
Returns
- IApplication
This instance for fluent API chaining. The created runnable is stored internally for disposal.
Type Parameters
TRunnableThe type of runnable to create and run. Must have a parameterless constructor.
Remarks
This is a convenience method that creates an instance of TRunnable and runs it.
The framework owns the created instance and will automatically dispose it when Shutdown() is called.
To access the result, use Shutdown() which returns the result from Result.
Supports fluent API: var result = Application.Create().Init().Run<MyView>().Shutdown() as MyResultType