Class EtoApp
Runs an Eto.Forms Eto.Forms.Application message loop on the calling (main) thread while executing program workload on a background thread. The workload can show GUI (e.g., via EtoDialogTaskHandler), which is marshaled back onto the main thread.
public static class EtoApp
- Inheritance
-
objectEtoApp
Remarks
Eto.Forms requires its Eto.Forms.Application to own the main thread (mandatory on macOS), and Eto.Forms.Application.Run() blocks. This helper inverts the usual "workload on main thread" model: the message loop owns the main thread and the workload runs on a worker thread.
Methods
Run(Platform, Action)
Runs workload on a worker thread while an Eto.Forms message loop runs on the calling (main) thread, then terminates the process with the workload's exit code. Does not return.
public static void Run(Platform platform, Action workload)
Parameters
platformPlatformThe Eto.Forms platform to run.
workloadActionThe program workload. Runs on a background thread; may show GUI which is marshaled to the main thread.
Remarks
When the workload completes, the process is terminated via Exit(int) with 0 on success, 1 if workload throws.
This is necessary because Eto.Forms.Application.Run() does not return after a quit on some platforms (e.g. macOS, where the native application loop exits the process directly), so the exit code cannot be propagated by returning from Eto.Forms.Application.Run().
Run(Platform, Func<int>)
Runs workload on a worker thread while an Eto.Forms message loop runs on the calling (main) thread, then terminates the process with the workload's exit code. Does not return.
public static void Run(Platform platform, Func<int> workload)
Parameters
platformPlatformThe Eto.Forms platform to run.
workloadFunc<int>The program workload. Runs on a background thread; may show GUI which is marshaled to the main thread. Returns the process exit code.
Remarks
When the workload completes, the process is terminated via Exit(int) with the workload's return value as the exit code. This is necessary because Eto.Forms.Application.Run() does not return after a quit on some platforms (e.g. macOS, where the native application loop exits the process directly), so the exit code cannot be propagated by returning from Eto.Forms.Application.Run().