When should settings be saved on Windows Phone 7?

I have a method for saving settings that I call, but I tried to unload and lost focus, the application closes and does not save before I ever get to any of these methods. When should I save application settings so that this does not happen?

Should I use a timer and save every 30 seconds or what?

+6
source share
2 answers

How often you save depends on your application. However, the key timings are:

  • Launch
  • Activated
  • MMG
  • Closing

Launching is called when the application is first launched from the main screen, and Closing is called when the user clicks the back button to exit your application. Naturally, you most likely want to keep persistent data in the Closing event.

Activated is called when the user has closed your application using the Windows button and returned to it by clicking the "Back" button. This is not called if the user launches the application for the first time.

Similarly, the Deactivated event is Deactivated when the user clicks the Windows button. Depending on your application, you want to save the transient data at this point, so that when recovering, you can present the illusion that your application was not closed at all. (Otherwise, for example, all text fields will become empty, even if the user enters data before pressing the Windows button).

These are major events, so you can create your own application around this. It should be remembered that if your save files are large and take longer than 10 seconds to save after the Closing event is Closing , your application will be terminated immediately, which will damage the save file. Therefore, for large save files, you should plan ahead, saving incrementally (for example, after the user has made changes that must remain constant).

There is no one size fits all solution, since preserving timings is highly dependent on the type of application being developed. Read the MSDN page of the runtime model , as it is discussed in more detail and contains code examples.

+10
source

Here is an example from MSDN on how to implement the settings page for Windows Phone.

http://msdn.microsoft.com/en-us/library/ff769510(v=vs.92).aspx

+1
source

Source: https://habr.com/ru/post/889819/


All Articles