I have a WPF application that needs to save its current state every time the application exits. At the moment, I am handling the System.Windows.Application.Exit
event to save the state of the application. However, it seems that the event is not invoked system reboots -- only ordinary shutdowns. Is this expected behavior?
This is what my application looks like.
public class MyApp : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
...
this.Exit += OnExit;
}
private void OnExit(object sender, ExitEventArgs e)
{
SaveMyApplicationState();
}
}
What events can I use to be notified of a system reboot, so my application state can be saved?