Tony 684 User Data App Services Arun 765 Thomas 762 Shell Kernel Shawn 626 App Roberth 779...

31

Transcript of Tony 684 User Data App Services Arun 765 Thomas 762 Shell Kernel Shawn 626 App Roberth 779...

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

ONE WINDOWS

PhoneDesktops

& All-in-OnesClassic Laptop

XboxTablet

Foreground 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

DEMOApplication Lifecycle

… but what if I need more time?

Extended ExecutionRunning Extension

Suspended

RequestExtension()

Revoked

Mem

ory

Suspended

Continue a session when not in the foreground

DEMOExtended Execution

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

DEMOExtended Execution

Background Execution

• Apps provide real-time content even when suspended

Background Execution

Draw users into your app

Delight them with features

Where did we come from?

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

DEMOBackground Tasks

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

DEMOApplication 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

DEMOSocket Trigger

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

© 2015 Microsoft Corporation. All rights reserved.