public async void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - {nameof(Run)} - Begun"); // Register the Monitoring Events taskInstance.Canceled += TaskInstance_Canceled; taskInstance.Task.Completed += Task_Completed; taskInstance.Task.Progress += Task_Progress; // Create the deferal and jump into the Task _deferral = taskInstance.GetDeferral(); // Create the Active theme Service var activeThemeService = new ActiveThemeService(); // Preform the service for the Active Desktop Theme var desktopTheme = activeThemeService.GetActiveDesktopTheme(); if (desktopTheme != null) { var desktopNextRunSetting = new ActiveDesktopThemeNextRunSetting(); if (DateTime.UtcNow >= desktopNextRunSetting.Value && desktopTheme.WallpaperChangeFrequency.TotalMilliseconds > 0.0) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Desktop - Changing Desktop Background"); await activeThemeService.NextDesktopBackground(); } else { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Desktop - Not enough time passed"); } } // Preform the service for the Active Lockscreen Theme var lockscreenTheme = activeThemeService.GetActiveLockscreenTheme(); if (lockscreenTheme != null) { var lockscreenNextRunSetting = new ActiveLockscreenThemeNextRunSetting(); if (DateTime.UtcNow >= lockscreenNextRunSetting.Value && lockscreenTheme.WallpaperChangeFrequency.TotalMilliseconds > 0.0) { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Lockscreen - Changing Lockscreen Background"); await activeThemeService.NextLockscreenBackground(); } else { Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - Active Lockscreen - Not enough time passed"); } } // Update the ActiveThemeLastRun ActiveThemeTaskLastRunSetting activeThemeTaskLastRun = new ActiveThemeTaskLastRunSetting(); activeThemeTaskLastRun.Value = DateTime.UtcNow; // Trigger the task is compelted Debug.WriteLine($"{nameof(ActiveThemeBackgroundTask)} - {nameof(Run)} - Completed"); _deferral.Complete(); }
public async void NextLockscreen() { await m_activeThemeService.NextLockscreenBackground(NextLockscreenImagePath); CurrentLockscreenImagePath = NextLockscreenImagePath; NextLockscreenImagePath = m_activeThemeService.GetNextLockscreenImagePath(); ActiveLockscreenThemeHistorySetting.RaiseValuePropertyChanged(); RaisePropertyChanged(nameof(CurrentLockscreenImage)); }
public async void SetLockscreenImage(FileDiscoveryCache cache) { await m_activeThemeService.NextLockscreenBackground(cache.FilePath); }