Reputation: 3218
I want to know what, how, and the limitations of the work that can be done whilst an app is suspended.
I'm not talking about Background Tasks
, since those run whether the app is suspended or not, but what you can do while the app is in the background, suspended.
What I noticed so far is that if I have a BackgroundTask
with the Completed
event attached in the MainApp, that trigger is fired whilst the app is suspended, meaning that I can in fact do work in the MainApp, with the app suspended. So far I only have two ways of doing that, one is by using a BackgroundTask
Completed
event, and the other is by having a timer that forces something to happen.
However, what, how and the limitations of what I can do with the suspended app are not clear to me.
So, is there another way of working with a suspended app? And how much CPU time do I have, if limited, to work with?
Upvotes: 2
Views: 364
Reputation: 280
You should check this link.
Understanding the App’s Lifecycle and Managing State - By Bob Tabor
Here its shown how you can manage to save the state of the app if your app is being suspended using suspension manager and also how to save data if the app is terminated from the suspension state.
Bob Tabor has clearly explained this in detail.
It was helpful to me, hope this helps you.
Upvotes: 0
Reputation: 3324
I have played around a bit and found out that MessageWebSocket
, if not disposed on app suspension, can still receive messages.
You could use the open socket connection to send messages, based on which you can execute code in the background.
A problem is when your app gets terminated by the OS (when the device does not have enough memory), then the socket connection will be closed too.
For more info on how to implement sockets see here.
Upvotes: 1