private void RegisterBackgroundTask(string taskName, string taskEntryPoint) { using (var fileService = new FileService()) { var localFoldeer = FileSystem.AppDataDirectory; var initFilePath = $"{localFoldeer}/init.bin"; var initFile = Task.Run(() => fileService.Read <InitFile>(initFilePath)).TryTo().Result; if (initFile.LastResetTime.TimeOfDay == DateTime.Now.TimeOfDay) { return; } if ((uint)(DateTime.Today.AddDays(1) - DateTime.Now).TotalMinutes < 15) { return; } var resetDailyTasks = new BackgroundTaskModel { Title = taskName, EntryPoint = taskEntryPoint, Trigger = GetTaskTrigger(taskName), OnComplete = new BackgroundTaskCompletedEventHandler(OnTaskComplete) }; GlobalDataService.UnregisterBackgroundTask(taskName); GlobalDataService.RegisterBackgroundTask(resetDailyTasks); } }
public App() { InitializeComponent(); // config.AppSettings.Clear(); Randomizer = new Random(); LoadThemeAndLanguage(); GlobalDataService.Init(); //(new TutorialListExample()).Create(); // For debug use. }