/// <summary> /// Run this method async to get the list of all /// the projects. /// </summary> /// <returns>List of all the projects.</returns> private async Task ScanProjectAsync() { IsProjectLoading = true; List <ProjectListItemViewModel> missingImageList = new List <ProjectListItemViewModel>(); ProjectList = new ReactiveList <ProjectListItemViewModel>(); var list = await Task.Run(() => _pm.GetProjectList()); foreach (var prj in list) { await System.Windows.Application.Current.Dispatcher.BeginInvoke(new System.Action(() => { // Create a project list item and add it to the list var prjVM = new ProjectListItemViewModel(prj, this); ProjectList.Add(prjVM); // Check if the project image exist if (prjVM.ProjectImage == null) { // Add name to list to later create image missingImageList.Add(prjVM); // Get the project for the image name //Project project = _pm.GetProject(prjVM.ProjectName); //// If the project image does not exist, create the image now //if (!File.Exists(project.GetProjectImagePath())) //{ // Task.Run(() => // { // prjVM.RefreshDisplay(); // this.NotifyOfPropertyChange(() => this.ProjectList); // }); //} } // Set the last selected project if (prj.ProjectID == _pm.GetSelectedProjectID()) { if (_pm.IsProjectSelected) { _SelectedProjectVM = prjVM; } else { SelectedProjectVM = prjVM; } _SelectedProjectVM.IsSelected = true; this.NotifyOfPropertyChange(() => this.SelectedProjectVM); } prj.Dispose(); })); } //// Load the missing project images 1 at a time. //// If a load them all it once, it takes to much memory //foreach (var prjVM in missingImageList) //{ // //Get the project for the image name // Project project = _pm.GetProject(prjVM.ProjectName); // // If the project image does not exist, create the image now // if (!File.Exists(project.GetProjectImagePath())) // { // Task.Run(() => // { // prjVM.RefreshDisplay(); // this.NotifyOfPropertyChange(() => this.ProjectList); // }); // } //} IsProjectLoading = false; }