/// <summary> /// Activate or deactivate the background task /// </summary> /// <param name="status">TRUE to activate and FALSE to deactivate.</param> /// <returns>TRUE if no error or FALSE in other case.</returns> public static async Task <bool> SetBackgroundTaskAsync(bool status) { if (status) { var task = await TaskService.RegisterBackgroundTaskAsync( TaskEntryPoint, TaskName, new TimeTrigger(TaskTimeTrigger, false)); if (task == null) { LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Can't enable CAMERA UPLOADS service (background tasks not allowed)"); return(false); } LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Enable CAMERA UPLOADS service"); await SdkService.GetCameraUploadRootNodeAsync(); return(true); } TaskService.UnregisterBackgroundTask(TaskEntryPoint, TaskName); LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Disable CAMERA UPLOADS service"); // Reset the date SettingsService.SaveSettingToFile(SettingsService.ImageDateSetting, DateTime.MinValue); return(true); }