12/5/2018 4:31 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
What’s new for multi-tasking in UWP? 12/5/2018 4:31 AM P4172 What’s new for multi-tasking in UWP? Chris Cortes Program Manager © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Multitasking and Background Activity 12/5/2018 4:31 AM Multitasking and Background Activity Background Task and Application Lifecycles New Multitasking Scenarios User Controls and Best Practices © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Process Lifecycle 12/5/2018 4:31 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Background Task Lifetime 12/5/2018 4:31 AM Background Task Lifetime Ideal Terminated Canceled Run() Run() Run() Cancel() Execution Time Default Background Tasks 25s Running time 5s Canceled time Separate Component Separate Project IBackgroundTask © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Application Lifecycle 12/5/2018 4:31 AM Application Lifecycle In-Process Introduced in the Anniversary Update App states Not Running Running Suspended App Callbacks Launched/On Activated Suspending/Resuming EnteredBackground/LeavingBackground © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Background Scenarios 12/5/2018 4:31 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Triggers Sensors Bluetooth Toasts Network System Trigger Local Data 12/5/2018 4:31 AM Triggers GattCharacteristicNotificationTrigger GattServiceProviderTrigger BluetoothLEAdvertisementWatcherTrigger BluetoothLEAdvertisementPublisherTrigger RfCommConnectionChangeTrigger DeviceUseTrigger DeviceConnectionTrigger DeviceServicingTrigger DeviceWatcherTrigger Sensors Bluetooth ToastNotificationActionTrigger ToastNotificationActionHistoryChangedTrigger UserNotificationChangedTrigger PushNotificationTrigger SocketActivityTrigger TimeTrigger MaintenanceTrigger Toasts Network UserAway UserPresent TimeZoneChange ServicingComplete PowerStateChange NetworkStateChange InternetAvailable AppointmentStoreNotificationTrigger ContactStoreNotificationTrigger EmailStoreNotificationTrigger CachedFileUpdaterTrigger Local Data System Trigger © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/5/2018 4:31 AM Trigger Demo © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Trigger Demo Recap Background Task Code in the Main App Project 12/5/2018 4:31 AM Trigger Demo Recap Background Task Code in the Main App Project Background Activated No Manifest Entry Required Registration Groups in Creators Update © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Background Task Registration Group 12/5/2018 4:31 AM Background Task Registration Group const string MyTaskGroupId = "4F8904E0-3F25-9A0C-41D3-0305E82C3333"; const string MyTaskGroupDebugName = "My Task Group"; var group = BackgroundTaskRegistration.GetTaskGroup(MyTaskGroupId); if (group == null) { group = new BackgroundTaskRegistrationGroup(MyTaskGroupId, MyTaskGroupDebugName); } var builder = new BackgroundTaskBuilder(); builder.Name = "Tasks Name"; builder.IsNetworkRequested = true; builder.TaskEntryPoint = "Tasks.MyTask"; builder.SetTrigger(myTrigger)); builder.TaskGroup = group builder.Register(); © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Activity Sponsored Execution 12/5/2018 4:31 AM Activity Sponsored Execution Manifest Entry <Capabilities> <uap3:Capability Name="backgroundMediaPlayback" /> </Capabilities> Press Play var player = new MediaPlayer(); player.Source = MediaSource.CreateFromUri(new Uri("https://contoso.com/song.mp3")); player.Play(); No Registration Code, No Background Management © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Extended Execution Run While Minimized Run Longer while Suspending 12/5/2018 4:31 AM Extended Execution Run While Minimized Location Tracking or Unspecified Run without a time limit Run Longer while Suspending Saving Data Revoked on a new activation Ensure good Resource Usage Time Limited on Battery Accepted into Windows Store © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Enterprise Restricted Capability Device Management Policy 12/5/2018 4:31 AM Enterprise Restricted Capability <Capabilities> <rescap:Capability Name="extendedBackgroundTaskTime"/> </Capabilities> Device Management Policy ./Vendor/MSFT/Policy/Config/Privacy/LetAppsRunInBackground ./Vendor/MSFT/Policy/Config/Privacy/LetAppsRunInBackground_ForceAllowTheseApps ./Vendor/MSFT/Policy/Config/Privacy/LetAppsRunInBackground_ForceDenyTheseApps ./Vendor/MSFT/Policy/Config/Privacy/LetAppsRunInBackground_UserInControlOfTheseApps © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/5/2018 4:31 AM User Controls © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Privacy User in control Controls all triggers Controls Generic EE 12/5/2018 4:31 AM Privacy User in control Controls all triggers Controls Generic EE Overridden by Group Policy © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Battery Usage Controls 12/5/2018 4:31 AM Battery Usage Controls Different UI per OS Edition Same Group Policy Same developer interface © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Respect User Control and Battery 12/5/2018 4:31 AM Respect User Control and Battery BackgroundAccessStatus backgroundStatus = await BackgroundExecutionManager.RequestAccessAsync(); AlwaysAllowed AllowedSubjectToSystemPolicy DeniedDueToSystemPolicy DeniedByUser BatteryStatus batteryStatus = Battery.AggregateBattery.GetReport().Status; Charging Discharging Idle NotPresent EnergySaverStatus status = PowerManager.EnergySaverStatus; Disabled, Off, On © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Extended Execution Demo 12/5/2018 4:31 AM Extended Execution Demo © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Extended Execution Demo Recap 12/5/2018 4:31 AM Extended Execution Demo Recap Test Lifetime off of the Debugger Extended Execution Session Background Access Status, Battery Status Direct User to Settings App if Needed © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Call to action Build any background scenario you can think of! 12/5/2018 4:31 AM Call to action Build any background scenario you can think of! Check out other Build session recordings on Channel 9. Use the Github samples and tutorials on the next slides. Continue your education at Microsoft Virtual Academy online. Provide Feedback on UserVoice. #MSBuild © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/5/2018 4:31 AM Related Sessions B8012 – Tips, Tricks and Secrets: Building a Great UWP App for Windows 10 P4050 – Bridges to UWP for Retail Point-Of-Sale Application Developers P4179 – Bluetooth GATT Server in Windows 10 #MSBuild © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/5/2018 4:31 AM Github Samples Out-Of-Proc Background Task: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BackgroundTask In-Proc Background Activation: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BackgroundActivation Background Media Playback: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BackgroundMediaPlayback Extended Execution: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/ExtendedExecution © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Tutorials App Lifecycle: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/app-lifecycle In-Proc Background Task: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-an-inproc-background-task Group Background Tasks: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/group-background-tasks Background Media Playback: https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/background-audio Extended Execution: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution Best Background Practices: https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/optimize-background-activity
12/5/2018 4:31 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.