Windows Developer Day Fall Creators Update October 10
Windows Developer Day Fall Creators Update October 10, 2017 Chris Cortes UWP Program Manager
Multitasking in the Fall Creators Update Single Process Model and Persistent Events Chris Cortes UWP Program Manager
Multitasking in UWP Single Process and Multiple Process Models Multitasking for your Scenario Persistent Events 3
Single Process Model Activate in Background Launch/Activated Background Activated New Callbacks Leaving Background Entered Background Suspended Terminated Foreground Resume Background Resume 4
Background Media Playback <Capabilities> Add Manifest Entry <uap 3: Capability Name="background. Media. Playback“ /> </Capabilities> Use any Windows Audio API Stream to hold Network var player = new Media. Player(); player. Source = Media. Source. Create. From. Uri(new Uri("https: //contoso. com/song. mp 3")); player. Play(); 5
Background Location Tracking private async void Start. Navigation(){ session = new Extended. Execution. Session(); Extended Execution Reason Check Background Access Request in Foreground session. Reason = Extended. Execution. Reason. Location. Tracking; session. Description = “Turn by Turn Navigation"; session. Revoked += session_Revoked; var result = await session. Request. Extension. Async(); if (result == Extended. Execution. Result. Allowed){ Start. Periodic. Location. Update(); } else { Check. Background. Access. And. Notify. User(); } } private async void session_Revoked(object sender, Extended. Execution. Revoked. Event. Args args){ if(args. Reason == Extended. Execution. Revoked. Reason. System. Policy){ Notify. User(); } } 6
Run While Minimized private async void Request. Background. Project. Compilation(){ session = new Extended. Execution. Session(); Extended Execution Reason Handle Request Result Handle Revoked Event session. Reason = Extended. Execution. Reason. Unspecified; session. Description = “Compile Project File"; session. Revoked += session_Revoked; var result = await session. Request. Extension. Async(); if (result == Extended. Execution. Result. Allowed){ Start. Compilation(); } else { Check. Background. Access. And. Notify. User(); } Battery-Aware } private async void session_Revoked(object sender, Extended. Execution. Revoked. Event. Args args){ if(args. Reason == Extended. Execution. Revoked. Reason. System. Policy){ Notify. User(); } } 7
Restricted Scenarios for Enterprise Extended. Background. Task. Time No Execution Time Exceeded on Background Tasks Background Access and Battery Saver still apply Extended. Execution. Unconstrained Extended. Execution. Foreground. Session Run while Minimized until Standby 8
Background Activation with Triggers New Triggers and Capabilities Added Each Release Multi-Instance Resource Grouping Task Grouping Background Activated Overridden Method in XAML Event on Core. Application Background Access Status User Controls in Settings Battery Saver 9
Persistent Event Creation Background Activation for Frameworks Separate Registrations from All. Tasks Background Task Registration Group Event Create Event Registration Token Table const string My. Task. Group. Id = "4 F 8904 E 0 -3 F 25 -9 A 0 C-41 D 3. 0305 E 82 C 3333"; const string My. Task. Group. Debug. Name = "My Task Group"; var group = Background. Task. Registration. Get. Task. Group(My. Task. Group. Id); if (group == null) { group = new Background. Task. Registration. Group(My. Task. Group. Id, My. Task. Group. Debug. Name); } var builder = new Background. Task. Builder(); builder. Name = "Tasks Name"; builder. Is. Network. Requested = true; builder. Task. Entry. Point = "Tasks. My. Task"; builder. Set. Trigger(my. Trigger)); builder. Task. Group = group; builder. Register(); 10
Persistent Event Usage Background Activation for Frameworks public App(){ this. Initialize. Component(); this. Suspending += On. Suspending; Persistent. Events. Maintenance. Window += Bg. Work. Maintenance; } App Subscribes to Event public static void Maintenance(object sender, Persistent. Event. Args e) { var def = e. Get. Deferral(); App Unsubscribes to Unregister Update. User. Content(); def. Complete(); } 11
Multitasking with the Single Process Model Background Media Playback Location Tracking Run While Minimized Restricted Scenarios for Enterprise Background Activation Persistent Events 12
Additional Information Single Process Model: https: //docs. microsoft. com/en-us/windows/uwp/launchresume/app-lifecycle Background Activation: https: //docs. microsoft. com/en-us/windows/uwp/launchresume/create-and-register-an-inproc-background-task Background Task Registration Groups: https: //docs. microsoft. com/enus/windows/uwp/launch-resume/group-background-tasks Manifest Attributes for Background Tasks: https: //docs. microsoft. com/enus/windows/uwp/launch-resume/declare-background-tasks-in-the-applicationmanifest 13
Code Samples Background Media Playback: https: //github. com/Microsoft/Windowsuniversal-samples/tree/master/Samples/Background. Media. Playback Extended Execution: https: //github. com/Microsoft/Windows-universalsamples/tree/master/Samples/Extended. Execution Background Activation: https: //github. com/Microsoft/Windowsuniversal-samples/tree/master/Samples/Background. Activation Persistent Events: https: //github. com/cc-cortes/Simple-Persistent. Events 14
© Copyright Microsoft Corporation. All rights reserved.
- Slides: 15