Lifecycle
Register a lifecycle handler before running the app:
CarbonApp.Create(config) .UseDesktop() .OnLifecycle(evt => { Console.WriteLine($"{evt.Kind}: {evt.Window?.Label}");
if (evt.Kind == CarbonLifecycleEventKind.ExitRequested && HasUnsavedWork()) evt.Cancel = true; }) .Run();Application events
Section titled “Application events”StartingReadyExitRequestedExitingExited
Window events
Section titled “Window events”WindowCreatingandWindowCreatedWindowCloseRequestedandWindowClosedWindowFocusedandWindowBlurredWindowMovedandWindowResizedWindowMinimized,WindowMaximized, andWindowRestored
ExitRequested and WindowCloseRequested can be cancelled. Plugins receive the same events through
IPlugin.OnLifecycleAsync, which is useful for flushing state or releasing native resources.
Desktop Run() starts the runtime, blocks in the platform message loop, and shuts down plugins in
reverse registration order. Mobile hosts call Start() and Shutdown() from their native lifecycle.
