Class App
Provides methods and properties to manage an application.
public class App : DisposableObject, IBaseObjectWithId, IDisposableObject, IDisposable, IBaseObject
- Inheritance
-
App
- Implements
- Derived
Constructors
- App(IApplicationHandler?)
Initializes a new instance of the App class.
Fields
- AppThreadId
Gets id of the application thread.
- BackendOS
Gets operating system as OperatingSystems enumeration.
- BuildCounter
Build counter for the test purposes.
- DeviceType
Gets device the app is running on, such as a desktop computer or a tablet.
- FastThreadExceptions
Gets or sets whether calls to and from native code are wrapped in "try catch".
- Handler
Gets application handler.
- InvariantEnglishUS
Gets invariant CultureInfo.
- 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.
- LogUnhandledThreadException
Gets or sets whether to log unhandled thread exception.
- ThreadExceptionExitCode
Gets or sets application exit code used when application terminates due to unhandled exception.
Properties
- AppClassName
Gets or sets the application class name.
- DebugWriteLine
Gets or sets whether to call WriteLine(string) when Log(object?, LogItemKind) is called. Default is
false
.
- DefaultIcon
Gets or sets default icon for the application.
- 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.
- HasApplication
Gets whether application was created and Current property is assigned.
- HasForms
Gets whether application has forms.
- HasHandler
Gets whether Handler is initialized.
- HasLogMessageHandler
Gets whether LogMessage event has any handlers.
- HasVisibleForms
Gets whether application has visible forms.
- InUixmlPreviewerMode
Gets whether application in Uixml previewer mode.
- 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.
- IsAppThread
Gets whether current thread is the thread which was used to initialize the application. It is better to use platform specific ways to get whether current thread is UI thread.
- IsArmOS
Gets whether the operating system architecture is Arm.
- IsArmProcess
Gets whether the process architecture of the currently running app is Arm.
- IsBusyCursor
Returns true if between two BeginBusyCursor() and EndBusyCursor() calls.
- IsDebuggerAttached
Gets a value that indicates whether a debugger is attached to the process.
- IsDesktopDevice
Gets whether device the app is running on is desktop.
- IsDesktopOs
Gets whether application is running on the desktop operating system.
- IsMaui
Gets whether application is executed on Maui platform.
- IsMono
Indicates whether the current application is running on Mono runtime.
- IsNetOrCoreApp
Returns True if application runs on Net or NetCore platform (Net 5 or higher). Returns False if application runs on Net Framework.
- IsPhoneDevice
Gets whether device the app is running on is phone.
- IsRunning
Gets whether execution is inside the Run(Window) method.
- IsTabletDevice
Gets whether device the app is running on is tablet.
- LangDirection
Gets the layout direction for the current locale or Default if it's unknown.
- LastActivatedWindows
Gets all visible windows in the application ordered by the last activated time. Last activated window will be the first one in the result.
- LastUnhandledException
Gets last unhandled exception.
- LastUnhandledExceptionThrown
Gets whether last unhandled exception was thrown.
- LogFileIsEnabled
Gets or sets whether to write all log messages to file.
- LogFilePath
Gets or sets application log file path.
- MainWindow
Gets main window.
- ModalDialogs
Gets collection of the visible modal dialogs.
- Name
Gets or sets the application name.
- PlatformKind
Gets currently used platform.
- SafeWindow
Gets ActiveWindow or MainWindow or FirstWindow(). The first not null value of these is returned.
- StartupPath
Gets the path for the executable file that started the application, not including the executable name.
- SupressDiagnostics
Allows to suppress some debug messages.
- Terminating
Gets whether Run(Window) method execution is finished.
- ThreadExceptionAssigned
Gets whether ThreadException event is assigned.
- ToolTipProvider
Gets or sets root tooltip provider.
- TopModalDialog
Gets top-most modal dialog or Null if no modal dialogs are shown.
- UnhandledExceptionMode
Gets how the application responds to unhandled exceptions. Use SetUnhandledExceptionMode(UnhandledExceptionMode) to change this property.
- UnhandledExceptionModeIfDebugger
Gets how the application responds to unhandled exceptions (if debugger is attached). Use SetUnhandledExceptionModeIfDebugger(UnhandledExceptionMode) to change this property.
- 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 the application.
- WakeUpIdleWithTimer
Uses timer to call WakeUpIdle() periodically. Default value is
true
. Default timeout value is DefaultWakeUpIdleTimeout.
- Windows
Gets the instantiated windows in the 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.
- AddLogItem(ListControlItem, LogItemKind)
Adds log item using the specified ListControlItem. LogListBox controls binded to the log will paint added item with image, font and color properties specified in the
item
.
- 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.
- CreateDefaultHandler()
Creates default application handler.
- DebugIdleLog(object?, LogItemKind)
Calls Log(object?, LogItemKind) method with
obj
parameter when application becomes idle. This method works only if DEBUG conditional is defined.
- DebugIdleLogIf(object?, bool, LogItemKind)
Calls Log(object?, LogItemKind) method with
obj
parameter when application becomes idle. This method works only if DEBUG conditional is defined andcondition
is True.
- DebugLog(object?)
Calls LogMessage event.
- DebugLogError(object?)
Logs error message.
- DebugLogIf(object?, bool)
Calls LogMessage event if
condition
istrue
.
- DebugLogReplace(object?, string?)
Calls LogMessage event to add or replace log message.
- DisposeManaged()
Override to dispose managed resources. Here we dispose all used object references.
- 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.
- ExitAndTerminate(int)
Calls Exit() and after that terminates this process and returns an exit code to the operating system.
- FindVisibleWindow<T>()
Finds first visible window of the specified type. If no window is found, returns Null.
- FindWindow<T>()
Finds first window of the specified type. If no window is found, returns Null.
- 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 theT
type.
- GetUnhandledExceptionMode()
Gets current unhandled exception mode.
- HandleThreadExceptions(Action)
Calls
action
inside try-catch block if specified by the exception handling settings FastThreadExceptions and GetUnhandledExceptionMode().
- HandleThreadExceptions<T>(Func<T>)
Calls
func
inside try-catch block if specified by the exception handling settings FastThreadExceptions and GetUnhandledExceptionMode().
- HasPendingEvents()
Checks whether there are any pending events in the queue.
- IdleLog(object?, LogItemKind)
Calls Log(object?, LogItemKind) method with
obj
parameter when application becomes idle.
- InvokeIdle(Action?)
Executes action in the application idle state using Invoke(Delegate?, object?[]?).
- InvokeIdleLog(object?, LogItemKind)
Executes IdleLog(object?, LogItemKind) using Invoke(Delegate?, object?[]?).
- Log(object?, LogItemKind)
Calls LogMessage event.
- LogBeginSection(string?, LogItemKind)
Begins log section.
- LogBeginUpdate()
Can be called before massive outputs to log. Pairs with LogEndUpdate().
- LogEmptyLine()
Logs an empty string.
- LogEndSection(LogItemKind)
Ends log section.
- LogEndUpdate()
Must be called after massive outputs to log, if LogBeginUpdate() was previously called.
- LogError(object?, LogItemKind, bool)
Logs error message.
- LogErrorIf(object?, bool)
Calls LogError(object?, LogItemKind, bool) if
condition
istrue
.
- LogErrorIfDebug(object?)
Logs error message if DEBUG is defined.
- LogIf(object?, bool, LogItemKind)
Calls LogMessage event if
condition
istrue
.
- LogInUpdates()
Gets whether massive log outputs are performed and controls attached to log should not refresh.
- LogNameValue(object, object?, LogItemKind?, string?)
Logs name, value and hint as "{name} = {value} ({hint})".
- LogNameValueIf(string, object?, bool, LogItemKind)
Logs name and value pair as "{name} = {value}" if
condition
istrue
.
- LogNameValueReplace(object, object?, LogItemKind?)
Logs name and value as "{name} = {value}". If last logged item starts from "{name} = ", it is repaced with the new item.
- LogNativeMessage(string)
Calls Log(object?, LogItemKind) after calling BeforeNativeLogMessage event.
- LogReplace(object?, object?, LogItemKind)
Calls LogMessage event to add or replace log message.
- LogSection(Action, string?)
Logs section using LogBeginSection(string?, LogItemKind), LogEndSection(LogItemKind) and calling
logAction
between them.
- LogSeparator(LogItemKind)
Logs separator.
- LogWarning(object?)
Logs warning message.
- OnThreadException(Exception)
Handles exception showing ThreadExceptionWindow dialog and calling exception related events if specified in the exception handling settings.
- ProcessIdleTask()
Runs single idle task if it is present.
- ProcessIdleTasks()
Runs idle tasks if they are present.
- ProcessLogQueue(bool)
Processes log queue.
- ProcessPendingEvents()
Processes all pending events.
- RaiseIdle()
Raises Idle event.
- 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 system option value by name.
- SetUnhandledExceptionMode(UnhandledExceptionMode)
Instructs the application how to respond to unhandled exceptions.
- SetUnhandledExceptionModeIfDebugger(UnhandledExceptionMode)
Instructs the application how to respond to unhandled exceptions in debug mode.
- SetUnhandledExceptionModes(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.
- ShowExceptionWindow(Exception, Action<bool>?)
Shows ThreadExceptionWindow on the screen.
- ShowExceptionWindow(Exception, string?, bool, bool, Action<bool>?)
Shows ThreadExceptionWindow on the screen.
- VisibleWindowsWithExcept(Window?)
Gets all visible windows in the application except the specified window.
- WakeUpIdle()
This function wakes up the (internal and platform dependent) idle system, i.e. it will force the system to send an idle event even if the system currently is idle and thus would not send any idle event until after some other event would get sent.
- WindowsWithExcept(Window?)
Gets all windows in the application except the specified window.
Events
- BeforeNativeLogMessage
Occurs before native debug message needs to be displayed.
- Idle
Occurs when the application finishes processing events and is about to enter the idle state.
- LogMessage
Occurs when debug message needs to be displayed.
- LogRefresh
Occurs when controls which display log messages need to be refreshed.
- ThreadException
Occurs when an untrapped thread exception is thrown.