: EDIT :.
If you have a generic application that does not have a MainWindow object, you probably want to click the "Suspend Event":
appObject.Suspending += (s, a) =>
{
SaveTheData(); // I really like my data and want it for later too
};
or
public App()
{
Suspending += (s, a) =>
{
SaveTheData();
};
}
.: Original :.
MainWindow "", . "" , "" .
theMainWindowObject.Closing += (s,a) =>
{
SaveTheData(); // It precious!
};
- , MainWindow "theMainWindowObject" "this",
, :
public MainWindow()
{
this.Closing += (s, a) =>
{
Save();
};
}
, :
public MainWindow()
{
Closing += (s, a) =>
{
Properties.Settings.Default.SettingsPopupX = mySettingsPopupObject.GetX();
Properties.Settings.Default.SettingsPopupY = mySettingsPopupObject.GetY();
Properties.Settings.Default.Save();
};
}