diff --git a/src/Uno.UI/UI/Xaml/Application.Android.cs b/src/Uno.UI/UI/Xaml/Application.Android.cs index c73a3d71aa18..cafbde82f58d 100644 --- a/src/Uno.UI/UI/Xaml/Application.Android.cs +++ b/src/Uno.UI/UI/Xaml/Application.Android.cs @@ -45,6 +45,7 @@ private SuspendingOperation CreateSuspendingOperation() => public void Exit() { + CoreApplication.Exiting?.Invoke(null, null); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); } } diff --git a/src/Uno.UI/UI/Xaml/Application.macOS.cs b/src/Uno.UI/UI/Xaml/Application.macOS.cs index abe96f32db3f..f0a924cae46c 100644 --- a/src/Uno.UI/UI/Xaml/Application.macOS.cs +++ b/src/Uno.UI/UI/Xaml/Application.macOS.cs @@ -164,6 +164,7 @@ partial void ObserveSystemThemeChanges() public void Exit() { + CoreApplication.Exiting?.Invoke(null, null); NSApplication.SharedApplication.Terminate(null); } diff --git a/src/Uno.UI/UI/Xaml/Application.skia.cs b/src/Uno.UI/UI/Xaml/Application.skia.cs index 348a16e97e02..1e8a59ccf5a2 100644 --- a/src/Uno.UI/UI/Xaml/Application.skia.cs +++ b/src/Uno.UI/UI/Xaml/Application.skia.cs @@ -15,6 +15,7 @@ using Uno.UI.Xaml; using Uno.Foundation.Extensibility; using System.Globalization; +using Windows.ApplicationModel.Core; namespace Windows.UI.Xaml { @@ -73,6 +74,8 @@ internal static void StartWithArguments(global::Windows.UI.Xaml.ApplicationIniti public void Exit() { + CoreApplication.Exiting?.Invoke(null, null); + if (_applicationExtension != null && _applicationExtension.CanExit) { _applicationExtension.Exit(); diff --git a/src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs b/src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs index 4ebd46135eeb..7a1981ac3011 100644 --- a/src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs +++ b/src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs @@ -62,6 +62,8 @@ static CoreApplication() public static CoreApplicationView GetCurrentView() => _currentView; + public static void Exit() => Application.Current.Exit(); + public static CoreApplicationView MainView => _currentView; public static IReadOnlyList Views => _views ??= new List() { _currentView }; diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.Core/CoreApplication.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.Core/CoreApplication.cs index 7d9ef8286ef3..8f81e6e0ec7f 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.Core/CoreApplication.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.Core/CoreApplication.cs @@ -68,8 +68,8 @@ public static void DecrementApplicationUseCount() } #endif // Forced skipping of method Windows.ApplicationModel.Core.CoreApplication.MainView.get - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ - [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] + #if false || __IOS__ || NET461 || __WASM__ || false || __NETSTD_REFERENCE__ || false + [global::Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__NETSTD_REFERENCE__")] public static void Exit() { global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.ApplicationModel.Core.CoreApplication", "void CoreApplication.Exit()"); @@ -141,8 +141,8 @@ public static void RunWithActivationFactories( global::Windows.Foundation.IGetAc } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ - [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] + #if false || __IOS__ || NET461 || __WASM__ || false || __NETSTD_REFERENCE__ || false + [global::Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__NETSTD_REFERENCE__")] public static event global::System.EventHandler Exiting { [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]