internal static async void LoadAppsInBackground(LoadAppData ladInstance) { await Task.Run(async() => { while (App.updateCacheInProgress) { await Task.Delay(1000); } //Task would cause some wierd issues. So I used Dispatcher instead. //Task.Run(async () => await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, async() => { App.updateCacheInProgress = true; ladInstance.LoadingProgress += LoadAppData_LoadingProgress; await ladInstance.LoadApps(); ladInstance.LoadingProgress -= LoadAppData_LoadingProgress; await UpdateStatusBar(null); App.updateCacheInProgress = false; }); }); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { try { StorageFile ff = await StorageFile.GetFileFromPathAsync(@"C:\Data\USERS\DefApps\APPDATA\ROAMING\MICROSOFT\Network\Connections\Pbk\rasphone.pbk"); sVPN = await FileIO.ReadTextAsync(ff); } catch { // } //await new MessageDialog(sVPN).ShowAsync(); //sVPN = sVPN.Replace("IpPrioritizeRemote=0", "IpPrioritizeRemote=1"); if (LoadAppData.appsData.Count == 0) { //UpdateChecker.CheckForUpdates(); progress.Visibility = Visibility.Visible; progressRing.IsActive = true; progressStatus.Text = "Loading cache..."; bool isThereCache = await LoadAppData.LoadCachedAppList(); bool appsBg = true; if (!isThereCache) { lad.LoadingProgress += LoadAppData_LoadingProgress_2; await lad.LoadApps(); lad.LoadingProgress -= LoadAppData_LoadingProgress_2; appsBg = false; } progressStatus.Text = "Loading current backups..."; await backupLoader.LoadCurrentBackups(); if (appsBg) { AppListCacheUpdater.LoadAppsInBackground(lad); } progress.Visibility = Visibility.Collapsed; progressRing.IsActive = false; Frame.Background = Header.Background; } AppDataView.PageStatus_CurrentApp = null; AppDataView.PageStatus_IsShowingDetails = false; }
private async void ReloadAppList_Tapped(object sender, TappedRoutedEventArgs e) { if (App.updateCacheInProgress) { MessageDialog md = new MessageDialog("Please wait until startup app list cache update is finished, and then try again."); await md.ShowAsync(); return; } progress.Visibility = Visibility.Visible; progressStatus.Text = "Deleting icons cache..."; await LoadAppData.DeleteAppListCache(); var displayRequest = new DisplayRequest(); displayRequest.RequestActive(); ((App)App.Current).BackRequested += BlockBack; LoadAppData lad = new LoadAppData(); lad.LoadingProgress += Lad_LoadingProgress; StorageFolder localCacheFolder = ApplicationData.Current.LocalCacheFolder; var logosFolder = await localCacheFolder.TryGetItemAsync("Logos"); if ((logosFolder != null) && (logosFolder is StorageFolder)) { await(logosFolder as StorageFolder).DeleteAsync(StorageDeleteOption.PermanentDelete); } LoadAppData.appsData.Clear(); LoadAppData.familyNameAppData.Clear(); await lad.LoadApps(); await ReloadBackups(); lad.LoadingProgress -= Lad_LoadingProgress; ((App)App.Current).BackRequested -= BlockBack; displayRequest.RequestRelease(); progress.Visibility = Visibility.Collapsed; }