Multitasking and Triggered Background Processing in Windows Phone 8.1
-
Upload
rob-irving -
Category
Software
-
view
1.220 -
download
5
Transcript of Multitasking and Triggered Background Processing in Windows Phone 8.1
Multitasking and Triggered Background Processing in Windows Phone 8.1
Rob IrvingSenior Software Engineer – ALK TechnologiesMicrosoft MVP – Windows Platform Developmentwww.robwirving.com@robwirving
Rob Irving• Senior Software Engineer at ALK Technologies• Microsoft MVP – Windows Platform Development• Led development effort to bring CoPilot GPS
navigation app to Windows Phone 8• In top 10 Free Navigation Apps in Window Phone store
• Windows Phone Dev by day and night• Released 7 of my own apps to Windows Phone store• http://bit.ly/AppsByRWI
• Blog: www.robwirving.com• Twitter: @robwirving
Agenda
• What are Background Tasks• History on Windows Phone 8• What’s new in Windows Phone 8.1• Triggered Background Tasks• Geofencing• XAML Tile Rendering
Multi-whosit?Triggered-what-the?
Where did we come from?
Apps not on screen are suspended
However apps can provide real-time content even when suspended
1. Live tiles or toasts2. Scheduled toasts and notifications 3. OS brokered tasks4. Background tasks and agents
Windows Phone multitasking model
Scheduled Task
PeriodicTask, ResourceIntensiveTask
Background Transfer Service
Background Location Tracking
VOIP and Audio Agents
Background Execution in WP8
Where are we going?
Centered around BackgroundTasks
Hosted in a separate process
Responds to Triggers and Conditions
One trigger per task, multiple conditions
Applications must request access to run in the background
Background Execution in WinRT
Basic TriggersTrigger Usage
System TriggerUserPresent , UserAway, SessionConnected, TimeZoneChange, NetworkStateChange, InternetAvailable, ServicingComplete
Run code on system events
TimeTrigger Data synchronization
MaintenanceTrigger Perform maintenance work on AC power
Background Tasks in Windows Store ApplicationsDEMO
What’s new?
Native Background Task functionality is available from Silverlight 8.1 applications
Background Agents are hosted on top of WinRT Background infrastructure
Windows Phone Silverlight 8.1 Apps
Bluetooth LE, RFComm and Sensors while not in foreground
Based on existing and new WinRT Bluetooth APIs
New Triggers:GattCharacteristicNotificationTriggerDeviceChangeTriggerDeviceUpdateTriggerRfcommConnectionTrigger
Bluetooth and Sensors
Associate a Background Task with WNS channel
RAW push notifications directly activate the Task
Push Triggers
Enables contextual or automatic experiences Used to start actions based on location
based notifications Delight the user with relevant proposals,
reminders, data… Get things done behalf of the user
automatically
What is a geofence and why use it
Geofence:virtual perimeter around a place of interest to an app/user
Geofence notifications can be received in the background by a background taskAdd a GeofenceGeocircle circle = new Geocircle(circleCenter, radius: 25.5);
Geofence geofence = new Geofence("LincolnSquareStore", circle);
GeofenceMonitor.Current.Geofences.Add(geofence);
Register a background TaskBackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.SetTrigger(new LocationTrigger(LocationTriggerType.Geofence));
Geofencing
Geofences have intuitive, easy-to-use properties.
Circular geofences are supported in this release.
A geofence consists ofProperty Required/optional Values Default
Id Required String N/A
Geoshape RequiredGeocircle (BasicGeoposition + Radius)
N/A
MonitoredStates Optional Entered/Exited/Removed Entered/Exited
SingleUse Optional True/False False
DwellTime Optional Timespan 10s
StartTime Optional DateTimeOffset 0/epoch
Duration Optional Timespan 0/forever
GeofencingDEMO
Render a Tile from your BackgroundTask!
New class XamlRenderingBackgroundTask BackgroundTask + XAML Visual Tree
Use RenderTargetBitmap to render XAML visual tree
XAML Rendering in BackgroundTask
XAML Rendering in BackgroundTaskDEMO
Windows.Networking.BackgroundTransfer
No file size restriction
Support for multi-part mime (for large transfers)
Additional verbs (PUT, RETR, STOR) and also FTP
In-progress stream access
Data-Sense and Battery Saver aware
BackgroundTransfer
What’s different?
OnlineIdConnectedStateChange
LockScreenApplicationAdded
LockScreenApplicationRemoved
ControlChannelTrigger
Not available on Windows Phone
Continuous Background Location
Runs-Under-Lock
VoIP Agents
Wallet Agents
Not available for Windows XAML applications
Battery Saver andResource Management
New in Windows Phone 8.1
Sort and manage which apps can execute in the background
Controls number of apps that can run in the background
Battery Saver
All background tasks have CPU, memory and network quotas
Quotas are based on actual CPU usage instead of wall clock time limits only
Wall-clock CPU quota will also be enforced (at least 30 secs)
Memory quota scales based on device capabilitiesTimeTrigger will have a 30 min floor on Phone
Call RequestAccessAsync() to get your full quota!
Resource constraints
Memory Constraints
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh977056.aspx#WP_EXTRA_RESOURCE_CONSTRAINTS
Build 2014 Sessions channel9.msdn.com/Events/Build/2014
Additional Resources
Blog: www.robwirving.com Twitter: @robwirving Apps: bit.ly/AppsByRWI LinkedIn: linkedin.com/in/robwirving Slideshare: slideshare.net/robwirving Samples: 1drv.ms/1oW9KYn