Table of Contents

Class Application

Namespace
Alternet.UI
Assembly
Alternet.UI.dll

Provides methods and properties to manage an application, such as methods to start and stop an application, and properties to get information about an application.

public class Application : IDisposable
Inheritance
Application
Implements

Examples

The following code shows how the Main method calls Run to start the Application event loop, with the given Window:

class Program
{
    [STAThread]
    public static void Main(string[] args)
    {
        var application = new Alternet.UI.Application();
        var window = new MainWindow();

        application.Run(window);

        window.Dispose();
        application.Dispose();
    }
}

Remarks

Use Run method to start running the UI event loop until the application is terminated. The Current property gets the object representing the currently running application.

Constructors

Application()

Initializes a new instance of the Application class.

Fields

BackendOS

Gets operating system as OperatingSystems enumeration.

Is64BitOS

Gets a value that indicates whether the current operating system is a 64-bit operating system.

Is64BitProcess

Gets a value that indicates whether the current process is a 64-bit process.

IsAndroidOS

Indicates whether the current application is running on Android.

IsIOS

Indicates whether the current application is running on Apple iOS.

IsLinuxOS

Returns true if operating system is Linux.

IsMacOS

Returns true if operating system is Apple macOS.

IsUnknownOS

Indicates whether the current application is running on unknown OS.

IsWindowsOS

Returns true if operating system is Windows.

Properties

AppClassName

Gets or sets the application class name.

Current

Gets the Application object for the currently runnning application.

DebugWriteLine

Gets or sets whether to call WriteLine(string) when
Log(object?) is called. Default is false.

DisplayName

Gets or sets the application display name.

ExitOnFrameDelete

Allows the programmer to specify whether the application will exit when the top-level frame is deleted. Returns true if the application will exit when the top-level frame is deleted.

Initialized

Gets whether application was initialized;

IsActive

Gets whether the application is active, i.e. if one of its windows is currently in the foreground.

IsBusyCursor

Returns true if between two BeginBusyCursor() and EndBusyCursor() calls.

IsDebuggerAttached

Gets a value that indicates whether a debugger is attached to the process.

IsDisposed

Gets whether Dispose(bool) has been called.

LayoutDirection

Gets the layout direction for the current locale or Default if it's unknown.

LogFileIsEnabled

Gets or sets whether to write all log messages to file.

LogFilePath

Gets or sets application log file path.

Name

Gets or sets the application name.

SupressDiagnostics

Allows to suppress some debug messages.

Terminating

Gets whether Run(Window) method execution is finished.

UseBestVisual

Gets or sets whether application will use the best visual on systems that support different visuals.

VendorDisplayName

Gets or sets the vendor display name.

VendorName

Gets or sets the vendor name.

VisibleWindows

Gets all visible windows in an application.

Windows

Gets the instantiated windows in an application.

Methods

AddIdleTask(Action)

Adds task which will be executed one time when the application finished processing events and is about to enter the idle state.

AddIdleTask(Action<object?>, object?)

Adds task which will be executed one time when the application finished processing events and is about to enter the idle state.

Alert(object?)

Instructs the application to display a dialog with an optional message, and to wait until the user dismisses the dialog.

BeginBusyCursor()

Changes the cursor to the given cursor for all windows in the application.

CreateAndRun(Func<Window>, Action?)

Creates application and main form, runs and disposes them.

DebugLog(object?)

Calls LogMessage event.

DebugLogIf(object?, bool)

Calls LogMessage event if condition is true.

DebugLogReplace(object?, string?)

Calls LogMessage event to add or replace log message.

Dispose()

Releases all resources used by the object.

Dispose(bool)

Releases the unmanaged resources used by the object and optionally releases the managed resources.

DoEvents()

Processes all messages currently in the message queue.

DoInsideBusyCursor(Action)

Executes action between calls to BeginBusyCursor() and EndBusyCursor().

EndBusyCursor()

Changes the cursor back to the original cursor, for all windows in the application.

Exit()

Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.

FirstWindow()

Returns first window or null if there are no windows.

FirstWindow<T>()

Returns first window or null if there are no windows or window is not of the T type.

HasPendingEvents()

Checks whether there are any pending events in the queue.

IsAndroidVersionAtLeast(int, int, int, int)

Checks if the Android version (returned by the Linux command uname) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version.

Log(object?)

Calls LogMessage event.

LogBeginSection(string?)

Begins log section.

LogEmptyLine()

Logs an empty string.

LogEndSection()

Ends log section.

LogError(object?)

Logs message with 'Error' prefix.

LogIf(object?, bool)

Calls LogMessage event if condition is true.

LogNameValue(string, object?)

Logs name and value pair as "{name} = {value}".

LogNameValueIf(string, object?, bool)

Logs name and value pair as "{name} = {value}" if condition is true.

LogReplace(object?, string?)

Calls LogMessage event to add or replace log message.

LogSeparator()

Logs separator.

LogWarning(object?)

Logs message with 'Warning' prefix.

ProcessPendingEvents()

Processes all pending events.

Run(Window)

Starts an application UI event loop and makes the specified window visible. Begins running a UI event processing loop on the current thread.

SetNativeTheme(string)

Allows runtime switching of the UI environment theme.

SetSystemOption(string, int)

Sets wxSystemOptions value.

SetUnhandledExceptionMode(UnhandledExceptionMode)

Instructs the application how to respond to unhandled exceptions.

SetUseBestVisual(bool, bool)

Allows the programmer to specify whether the application will use the best visual on systems that support several visual on the same display.

Events

Idle

Occurs when the application finishes processing and is about to enter the idle state.

LogMessage

Occurs when debug message needs to be displayed.

ThreadException

Occurs when an untrapped thread exception is thrown.

VisualThemeChanged

Occurs when the VisualTheme property changes.