Hello All,
Sharing some notes on Background task.
Sharing some notes on Background task.
- Background task allow us to run our code when our app is not in foreground.
- Starting with Windows 10, you no longer need to place an app on the lock screen in order to register background tasks.
- Background tasks are limited to 30 seconds of wall-clock usage.
- Respect Cost : Add BackgroundWorkCostValue in run() to get access on priority from system.
- Querying cost can prevent cancellations and incomplete operations.
- Handle System Cancellations:
- Use defferal for any asynchronous operations.
- App can have more than one Background Task.
- If get the permission then build and register task(add triggers, add system conditions, task.register())
- Some of the Triggers : DeviceWatcherTrigger , ActivitySensorTrigger , SensorDataThresholdTrigger, ToastNotificationHistoryChangedTrigger, ToastNotificationActionTrigger,AppointmentStoreNotificationTrigger, ContactStoreNotificationTrigger, EmailStoreNotificationTrigger, BluetoothLEAdvertisementWatcherTrigger, BluetoothLEAdvertisementPublisherTrigger, MediaProcessingTrigger,SocketActivityTrigger
- User Invoked Constraints: Quite Hours(No toast, No Background task,Active task are cancelled). Still Allowed VOIP toast and Alarm toast.
- Debugging : Visual studio can trigger,Application logs = Appication & Services Logs ->Microsoft -> BackgroundTaskInfrastructure