1 / 15

Windows Developer Day

Learn about multitasking in the Fall Creators Update with the single process model and persistent events. Explore background media playback, location tracking, running while minimized, and restricted scenarios for enterprise.

lydiae
Download Presentation

Windows Developer Day

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Developer Day Fall Creators Update • Chris Cortes • UWP Program Manager • October 10, 2017

  2. Multitasking in the Fall Creators Update Single Process Model and Persistent Events • Chris Cortes • UWP Program Manager

  3. Multitasking in UWP • Single Process and Multiple Process Models • Multitasking for your Scenario • Persistent Events

  4. Single Process Model • Activate in Background • Launch/Activated • Background Activated • New Callbacks • Leaving Background • Entered Background • Suspended • Terminated • Foreground Resume • Background Resume

  5. Background Media Playback • Add Manifest Entry • Use any Windows Audio API • Stream to hold Network • <Capabilities> • <uap3:CapabilityName="backgroundMediaPlayback“ /> • </Capabilities> • var player = newMediaPlayer(); • player.Source = MediaSource.CreateFromUri(newUri("https://contoso.com/song.mp3")); • player.Play();

  6. Background Location Tracking • Extended Execution Reason • Check Background Access • Request in Foreground • privateasyncvoidStartNavigation(){ • session = newExtendedExecutionSession(); • session.Reason = ExtendedExecutionReason.LocationTracking; • session.Description = “Turn by Turn Navigation"; • session.Revoked += session_Revoked; • var result = awaitsession.RequestExtensionAsync(); • if (result == ExtendedExecutionResult.Allowed){ • StartPeriodicLocationUpdate(); • } • else { CheckBackgroundAccessAndNotifyUser(); } • } • privateasyncvoidsession_Revoked(object sender, ExtendedExecutionRevokedEventArgsargs){ • if(args.Reason == ExtendedExecutionRevokedReason.SystemPolicy){ • NotifyUser(); • } • }

  7. Run While Minimized • Extended Execution Reason • Handle Request Result • Handle Revoked Event • Battery-Aware • privateasyncvoidRequestBackgroundProjectCompilation(){ • session = newExtendedExecutionSession(); • session.Reason = ExtendedExecutionReason.Unspecified; • session.Description = “Compile Project File"; • session.Revoked += session_Revoked; • var result = awaitsession.RequestExtensionAsync(); • if (result == ExtendedExecutionResult.Allowed){ • StartCompilation(); • } • else { CheckBackgroundAccessAndNotifyUser(); } • } • privateasyncvoidsession_Revoked(object sender, ExtendedExecutionRevokedEventArgsargs){ • if(args.Reason == ExtendedExecutionRevokedReason.SystemPolicy){ • NotifyUser(); • } • }

  8. Restricted Scenarios for Enterprise • ExtendedBackgroundTaskTime • No Execution Time Exceeded on Background Tasks • Background Access and Battery Saver still apply • ExtendedExecutionUnconstrained • ExtendedExecutionForegroundSession • Run while Minimized until Standby

  9. 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 CoreApplication • Background Access Status • User Controls in Settings • Battery Saver

  10. Persistent Event Creation • . • Background Activation for Frameworks • Separate Registrations from AllTasks • Background Task Registration Group Event • Create Event Registration Token Table conststringMyTaskGroupId = "4F8904E0-3F25-9A0C-41D3-0305E82C3333"; conststringMyTaskGroupDebugName = "My Task Group"; var group = BackgroundTaskRegistration.GetTaskGroup(MyTaskGroupId); if (group == null) {      group = newBackgroundTaskRegistrationGroup(MyTaskGroupId, MyTaskGroupDebugName); } var builder = newBackgroundTaskBuilder(); builder.Name = "Tasks Name"; builder.IsNetworkRequested = true; builder.TaskEntryPoint = "Tasks.MyTask"; builder.SetTrigger(myTrigger)); builder.TaskGroup = group; builder.Register();

  11. Persistent Event Usage • Background Activation for Frameworks • App Subscribes to Event • App Unsubscribes to Unregister • public App(){ • this.InitializeComponent(); • this.Suspending += OnSuspending; • PersistentEvents.MaintenanceWindow += BgWork.Maintenance; • } • publicstaticvoid Maintenance(object sender, PersistentEventArgs e){ • vardef = e.GetDeferral(); • UpdateUserContent(); • def.Complete(); •  }

  12. Multitasking with the Single Process Model • Background Media Playback • Location Tracking • Run While Minimized • Restricted Scenarios for Enterprise • Background Activation • Persistent Events

  13. Additional Information • Single Process Model: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/app-lifecycle • Background Activation: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-an-inproc-background-task • Background Task Registration Groups: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/group-background-tasks • Manifest Attributes for Background Tasks: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/declare-background-tasks-in-the-application-manifest

  14. Code Samples • 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 • Background Activation: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BackgroundActivation • Persistent Events: https://github.com/cc-cortes/Simple-Persistent-Events

More Related