Class Application
Represents an abstract base class for Xui applications. This class is paired at runtime with a platform-specific counterpart, which delegates to actual system APIs on macOS, Windows, Android, etc.
Users should subclass Application, override the Start() method, and call Run() to launch the application.
public abstract class Application : IServiceProvider
- Inheritance
-
Application
- Implements
- Inherited Members
- Extension Methods
Constructors
Application(IServiceProvider)
Initializes a new instance of the Application class.
public Application(IServiceProvider context)
Parameters
contextIServiceProvider
Properties
Context
The service provider for this application.
public IServiceProvider Context { get; }
Property Value
DisposeQueue
A list of disposables that are disposed when the application exits.
public List<IDisposable> DisposeQueue { get; }
Property Value
Runtime
The platform runtime used by this application.
public IRuntime Runtime { get; }
Property Value
Methods
GetService(Type)
Gets the service object of the specified type.
public virtual object? GetService(Type serviceType)
Parameters
serviceTypeTypeAn object that specifies the type of service object to get.
Returns
- object
A service object of type
serviceType.-or-
null if there is no service object of type
serviceType.
OnExit()
Called by run loops that have a definite exit point (e.g. Win32, macOS) just before their Run() returns. Not called on platforms whose run loop never exits (iOS, Browser canvas), so do not rely on this for cleanup that must always run.
public virtual void OnExit()
Quit()
Requests graceful shutdown of the application's run loop. On platforms without a blocking run loop (iOS, Browser) this is a no-op.
public virtual void Quit()
Run()
Starts the main application loop by delegating to the platform-specific run loop. This method may block until the application exits, or may return immediately if the platform bootstraps a runtime loop before instantiating the app delegate.
public virtual int Run()
Returns
- int
The application’s exit code.
Start()
Called by the runtime after initialization. Override this method to set up application state and display the initial UI.
public abstract void Start()
Events
Exit
Raised when the application exits on platforms with a definite exit point. See OnExit() for the same constraint on when this fires.
public event Action? Exit