0
votes

I have a windows 8.1/windows phone 8.1 (WinRT) app published in the windows store. The app uses the Windows.UI.Xaml.Application.Suspending event handler to save important app state and statistics into a set of files (not using the built-in settings API for a reason). In order to be "a good boy" I try to comply with the Windows.ApplicationModel.SuspendingOperation.Deadline and call the Windows.ApplicationModel.SuspendingOperation.GetDeferral() to be as explicit as possible.

Here are the questions:

  1. Do I get it right that I have to call the Windows.ApplicationModel.SuspendingDeferral.Complete() method before the moment of deadline?

  2. Are there any noticeable penalties if I do not manage to call it before the deadline? Does it make my app "unresponsive" from the point of view of some system watchful eye?

  3. What happens with the threads that are still running in the moment the Windows.ApplicationModel.SuspendingDeferral.Complete() is called? Do they get frozen or something?

  4. Is there any difference in behavior between "async" threads i.e. implicit TPL threads or ThreadPool.RunAsync and UI thread in the process of app suspending?

  5. Am I obligated to explicitly cancel all the async Tasks i.e. System.Threading.Tasks.Task instances I own before I call the Windows.ApplicationModel.SuspendingDeferral.Complete()?

1

1 Answers

1
votes

Here is a very good article about RT app life cycle: What You Need To Know About Suspend and Resume in WinRT.

If you don’t call Complete method before the SuspendingOperation.Deadline expires, a timeout occurs and Windows guesses that something bad happened to your app… and, instead of being suspended, it will be terminated.

So, you should finish your job and call Complete before Dedline.