Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save data when Windows 8 Store app closes

I have written a windows 8 store app (XAML/C#) which I have running on a Microsoft surface. The app is basically a data entry application which doesn't have any save buttons. Saving is performed automatically when jumping between pages or when the application is suspended.

However one senario I can't seem to catch is when the user closes the application (when the users swipes from the top to bottom of the screen).

So at the moment I subscribe to App.Current.Suspending and call save here:

App.Current.Suspending += Current_Suspending;                  

void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
{
    Save();
}

I also override the SaveState method and call Save here:

protected override void SaveState(Dictionary<string, object> pageState)
{
    Save();
    base.SaveState(pageState);
}

But niether of these methods are called when the application is closed.

Does anybody know of an event that gets fired when the app closes?

Thanks

like image 465
Sun Avatar asked Apr 23 '13 11:04

Sun


People also ask

Where do Windows applications Store data?

Programs and apps downloaded from the Microsoft Store are installed in the following path by default: C:/Program Files/WindowsApps (Hidden items).

How do I stop Microsoft Store from closing?

Select the Start button, and then select Settings > Update & Security > Troubleshoot, and then from the list select Windows Store apps > Run the troubleshooter. Press the Windows Key + S and type in services. msc. If Disabled, change it to Automatic, click Start and click OK.

Why is Microsoft Store app closing?

Here are the most common causes for the Microsoft Store frequently crashing on Windows 10: Your Windows Store cache is damaged, corrupted, or you don't have enough available space on the drive. The time and date settings on your computer are incorrect. The Microsoft Store app is damaged or corrupted.


1 Answers

http://msdn.microsoft.com/en-US/library/windows/apps/xaml/hh465115.aspx

At the bottom it contains the following note:

A note about debugging using Visual Studio: Visual Studio prevents Windows from suspending an app that is attached to the debugger. This is to allow the user to view the Visual Studio debug UI while the app is running. When you're debugging an app, you can send it a suspend event using Visual Studio. Make sure the Debug Location toolbar is being shown, then click the Suspend icon.

like image 115
ChristiaanV Avatar answered Sep 25 '22 08:09

ChristiaanV