Skip to content

Commit

Permalink
feat: Support for CoreApplication.Exit and Exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Sep 27, 2022
1 parent f2e1583 commit dfbaf17
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Uno.UI/UI/Xaml/Application.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private SuspendingOperation CreateSuspendingOperation() =>

public void Exit()
{
CoreApplication.Exiting?.Invoke(null, null);
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Uno.UI/UI/Xaml/Application.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ partial void ObserveSystemThemeChanges()

public void Exit()
{
CoreApplication.Exiting?.Invoke(null, null);
NSApplication.SharedApplication.Terminate(null);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Uno.UI.Xaml;
using Uno.Foundation.Extensibility;
using System.Globalization;
using Windows.ApplicationModel.Core;

namespace Windows.UI.Xaml
{
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CoreApplicationView> Views => _views ??= new List<CoreApplicationView>() { _currentView };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()");
Expand Down Expand Up @@ -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<object> Exiting
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
Expand Down

0 comments on commit dfbaf17

Please sign in to comment.