I have the following problem: I save(xml serialize) my configuration(very large list of object) on app exit, main form closing , but sometimes OS (win 7) on some comps terminates my app before the save is finished. So I’m asking when is the best time to do this , I thought maybe on main form minimize,but that to conditional(user maybe will never minimize the app).
I have the following problem: I save(xml serialize) my configuration(very large list of object)
Share
WPF Only
have you tried putting it in your application class? There is an override that fires on application exit. The method below takes 10 seconds to complete it’s task and also makes the user click the OK button on the messagebox before the application closes.
this will not work if you’re saving your config in another thread though, it’ll just exit the application.
App.xaml.cs
Win Forms
in Winforms applications you can hook on to the ApplicationExit event and save your config there.