/// <summary> /// Closes the current application. The actual implementation depends on the final target framework. /// </summary> /// <returns><c>true</c> if the application is closed; otherwise <c>false</c>.</returns> public bool CloseApplication() { var eventArgs = new ApplicationClosingEventArgs(); ApplicationClosing.SafeInvoke(this, eventArgs); if (eventArgs.Cancel) { return(false); } ApplicationClosed.SafeInvoke(this); return(true); }
/// <summary> /// Closes the current application. The actual implementation depends on the final target framework. /// </summary> /// <returns><c>true</c> if the application is closed; otherwise <c>false</c>.</returns> public bool CloseApplication() { var eventArgs = new ApplicationClosingEventArgs(); ApplicationClosing?.Invoke(this, eventArgs); if (eventArgs.Cancel) { Log.Info("Closing of application is canceled"); return(false); } CloseMainWindow(); #pragma warning disable 162 ApplicationClosed?.Invoke(this, EventArgs.Empty); return(true); #pragma warning restore 162 }
/// <summary> /// Closes the current application. The actual implementation depends on the final target framework. /// </summary> /// <returns><c>true</c> if the application is closed; otherwise <c>false</c>.</returns> public bool CloseApplication() { var eventArgs = new ApplicationClosingEventArgs(); ApplicationClosing.SafeInvoke(this, eventArgs); if (eventArgs.Cancel) { Log.Info("Closing of application is canceled"); return(false); } #if NET || SL4 || SL5 _appClosedFromService = true; var mainWindow = Catel.Environment.MainWindow; if (mainWindow == null) { const string error = "No main window found (not running SL out of browser? Cannot close application without a window."; Log.Error(error); throw new NotSupportedException(error); } if (!_appClosingByMainWindow) { mainWindow.Close(); } #else Log.Error("Closing an application is not possible in '{0}'", Platforms.CurrentPlatform); throw new NotSupportedInPlatformException("Closing an application is not possible"); #endif #pragma warning disable 162 ApplicationClosed.SafeInvoke(this); return(true); #pragma warning restore 162 }
public void OnApplicationClosed() { ApplicationClosed?.Invoke(null, null); }