diff --git a/WpfExtended.Test/Launcher.cs b/WpfExtended.Test/Launcher.cs
index 76bcc0d..a28f084 100644
--- a/WpfExtended.Test/Launcher.cs
+++ b/WpfExtended.Test/Launcher.cs
@@ -15,6 +15,14 @@ namespace WpfExtended.Tests
return Instance.Run();
}
+ protected override void ApplicationClosing()
+ {
+ }
+
+ protected override void ApplicationStarting()
+ {
+ }
+
protected override bool HandleException(Exception e)
{
return false;
diff --git a/WpfExtended/Launch/ExtendedApplication.cs b/WpfExtended/Launch/ExtendedApplication.cs
index 586bf61..cf637ba 100644
--- a/WpfExtended/Launch/ExtendedApplication.cs
+++ b/WpfExtended/Launch/ExtendedApplication.cs
@@ -18,6 +18,14 @@ namespace System.Windows.Extensions
this.RegisterInternals();
}
+ ///
+ /// Called right before the window is shown.
+ ///
+ protected abstract void ApplicationStarting();
+ ///
+ /// Called right before the application is closing.
+ ///
+ protected abstract void ApplicationClosing();
///
/// Register services into the .
///
@@ -34,12 +42,25 @@ namespace System.Windows.Extensions
{
this.SetupExceptionHandling();
this.RegisterServices(this.ServiceManager);
+ this.SetupApplicationLifetime();
this.LaunchWindow();
}
+ protected sealed override void OnExit(ExitEventArgs e)
+ {
+ base.OnExit(e);
+ this.ApplicationClosing();
+ }
+ protected sealed override void OnSessionEnding(SessionEndingCancelEventArgs e)
+ {
+ base.OnSessionEnding(e);
+ this.ApplicationClosing();
+ }
+
private void LaunchWindow()
{
var window = this.ServiceManager.GetService();
+ this.ApplicationStarting();
window.Show();
}
private void RegisterInternals()
@@ -70,5 +91,9 @@ namespace System.Windows.Extensions
}
};
}
+ private void SetupApplicationLifetime()
+ {
+ AppDomain.CurrentDomain.ProcessExit += (s, e) => this.ApplicationClosing();
+ }
}
}
diff --git a/WpfExtended/WpfExtended.csproj b/WpfExtended/WpfExtended.csproj
index 36875fd..a4aae2b 100644
--- a/WpfExtended/WpfExtended.csproj
+++ b/WpfExtended/WpfExtended.csproj
@@ -6,7 +6,7 @@
true
true
License.txt
- 0.1
+ 0.1.1
Extension library for Windows Presentation Platform.
Credits: