public void UnRegisterBackgroundTasks()
 {
     BackgroundTasksHelper.UnregisterBackgroundTasks(SYSTEM_TRIGGERED_TASK_NAME);
     isSystemTaskRegistered = false;
     BackgroundTasksHelper.UnregisterBackgroundTasks(TIME_TRIGGERED_TASK_NAME);
     isTimeTaskRegistered = false;
 }
        public async Task RegisterBackgroundTasks()
        {
            isSystemTaskRegistered = GetTaskStatus(SYSTEM_TRIGGERED_TASK_NAME);
            isTimeTaskRegistered   = GetTaskStatus(TIME_TRIGGERED_TASK_NAME);

            if (!isSystemTaskRegistered)
            {
                var trigger = new SystemTrigger(SystemTriggerType.UserPresent | SystemTriggerType.SessionConnected, false);
                SytemTriggeredBackgroundTask = await BackgroundTasksHelper.RegisterBackgroundTask(ENTRY_POINT,
                                                                                                  SYSTEM_TRIGGERED_TASK_NAME,
                                                                                                  trigger,
                                                                                                  null,
                                                                                                  true);

                isSystemTaskRegistered = true;
            }

            if (!isTimeTaskRegistered)
            {
                SystemCondition userPresentCondition = new SystemCondition(SystemConditionType.UserPresent);
                TimeTriggeredBackgroundTask = await BackgroundTasksHelper.RegisterBackgroundTask(ENTRY_POINT,
                                                                                                 TIME_TRIGGERED_TASK_NAME,
                                                                                                 new TimeTrigger(BACKGROUND_RATE, false),
                                                                                                 userPresentCondition,
                                                                                                 true);

                isTimeTaskRegistered = true;
            }
        }