tony 684 user data app services arun 765 thomas 762 shell kernel shawn 626 app roberth 779...
TRANSCRIPT
Shawn HenryProgram ManagerWindows Developer Ecosystem Platform
Windows App Lifecycle From Activation & Suspension to Background Execution and Multitasking
3-626
Tony684
User Data
App Services
Arun765
Thomas762
Shell
Kernel
Shawn626
Title: Windows 10 App Lifecycle: From Activation & Suspension to Background Execution and MultitaskingCode: 626Speaker: Shawn HenryRoom: TBDDate: 4/29Time: 2.00
App
Roberth779
Enterprise JohnIgnite
Store Barclay695
Andrew617
App ModelApplication Model Map
How Windows interacts with you app
Suspend and resume
Background execution
Resource management
System triggers and notifications
Application Lifecycle
Application LifetimeApps can be in 1 of 3 states
Not RunningRunningSuspended
Application receive events when transitioning between states
Except: Suspended->NotRunning
Running
SuspendedNotRunning
Activated Suspending
Resuming
Application Lifetime
Running Suspended Running Suspended Not Running
Activated Suspended Resumed Suspended
Usa
ge
CPU
Memory
Extended ExecutionRunning Extension
Suspended
RequestExtension()
Revoked
Mem
ory
Suspended
Continue a session when not in the foreground
Extended ExecutionRunning Extension
NavigatedAway
Request
Revoked
Mem
ory
Not Running
Suspend
Applications must supply a reason
Revoked events will have <1 sec to clean up
• Apps provide real-time content even when suspended
Background Execution
Draw users into your app
Delight them with features
PLATFORM CONVERGENCE HAS BEEN A JOURNEY
Windows Phone 7.5
Windows Phone 8
Windows Phone 8.1
Windows 8
Xbox One
IoT
Windows 8.1
Windows 10
Convergedbackground
model
Trigger based Background TasksApps subscribe to triggers they are interested inOnly run *when* trigger is fired
Example:Push notificationGeofencingBLE deviceTimerApp Services
private void RegisterBackgroundTasks(){ BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.Name = "Background Test Class"; builder.TaskEntryPoint = "BackgroundTaskLibrary.TestClass";
IBackgroundTrigger trigger = new TimeTrigger(30, true); builder.SetTrigger(trigger); IBackgroundCondition condition = new SystemCondition(SystemConditionType.InternetAvailable); builder.AddCondition(condition);
IBackgroundTaskRegistration task = builder.Register();
task.Progress += new BackgroundTaskProgressEventHandler(task_Progress); task.Completed += new BackgroundTaskCompletedEventHandler(task_Completed);}
Registering a background task
SystemTriggerTimeTriggerMaintenanceTriggerDeviceUseTriggerDeviceServicingTriggerPushNotificationTrigger
CachedFileUpdaterTriggerDeviceConnectionChangeTriggerGattCharacteristicNotificationTriggerRfcommConnectionTriggerLocationTrigger
AppointmentStoreNotificationTriggerContactStoreNotificationTriggerBluetoothLEAdvertisementWatcherTriggerBluetoothLEAdvertisementPublisherTriggerDeviceWatcherTriggerActivitySensorTriggerSensorDataThresholdTriggerToastNotificationHistoryChangedTriggerToastNotificationActionTriggerApplicationTriggerMediaProcessingTriggerSocketActivityTrigger
TriggersW
indow
s 8
.1W
P 8
.1
Win
dow
s 10
Default Background TasksGuaranteed minimum execution time of 25 secs
Example 512MB Mobile device
Resource Management
Run()Cancel()
Mem
ory
Run()
Task type
Memory Cap MB
Lifetime CPU
Block in Batt-Sav
Default Background Task 16 30 sec 10% Y
Long-Running 16 ∞ 10% Y
Opportunistic Background Tasks
Run for as long as resources are availableNo guarantee of executionApplicationTrigger, MaintenanceTrigger, DeviceUseTrigger
Default Oppurtunistic
In-Proc Background TasksApp Container
app.exe
CoreApplication
BackgroundTask
App Container
app.exe
CoreApplication
BackgroundTask
backgroundtaskhost.exe
Default Background Task
Hosted in a separate processWith separate memory caps
In Proc Background Task
Hosted in the specified processShares memory caps
<Extension Category="windows.backgroundTasks" EntryPoint="BackgroundTasks.TimerTask“Executable="InProcBackgroundTask.exe">
Same as app exe
• Opportunistic task• Triggered from the foreground application• Useful for initial syncing of data
Application Trigger
Apps can have network connectivity and discoverability maintained while suspended or even terminated.Alternative to WNS triggered Tasks
How it works:In foreground app process:Create/retrieve socket(s)Register background task to be woken upGive socket to broker service as app is suspendingTake socket back from broker service at any time
On incoming network activity on brokered socket:Background task is triggeredTake socket back from broker service
Socket Trigger Tasks
Wrap up
1. Background processing is converged with Windows2. There are lots of new things you can do3. But resources are still limited
Other SessionsSession
When/Where Title Speakers
2-684 Thurs 2.00 Room 2005
User Data: Working with Contacts, Appointments, Text Messages and More on Windows 10Tony
Tony Pendolino, Adam Wilson
3-739 Fri 10.30Room 3022
Building Compelling Bluetooth Apps in Windows 10
Todd Paris, Kiran Pathakota, Ellick Sung
3-779 Fri 10.30Room 2004
Navigation and Windowing in Universal Windows Apps
Roberth Karman, Andrew Bares
2-762 Fri 12.30Room 2005
Tiles, Notifications, and Action Center Thomas Fennel, Lei Xu
3-765 Fri 2.00Room 2004
App-to-App Communication: Building a Web of Apps
Sandeep Mathew George, Arunjeet Singh Questions?
Meet me in the Insider’s Lounge or @shawnhenry