Browse Source

Fix crash when opening start page.

pull/32/merge
Daniel Grunwald 13 years ago
parent
commit
a07f492feb
  1. 43
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs

43
src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs

@ -8,6 +8,7 @@ using System.ComponentModel; @@ -8,6 +8,7 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
@ -40,35 +41,31 @@ namespace ICSharpCode.StartPage @@ -40,35 +41,31 @@ namespace ICSharpCode.StartPage
set { SetValue(HeaderProperty, value); }
}
void BuildRecentProjectList()
async void BuildRecentProjectList()
{
// When building the project list we access the .sln files (to see if they still exist).
// Because those might be stored on a slow network drive, we do this on a background thread so that
// SharpDevelop startup doesn't have to wait.
ThreadPool.QueueUserWorkItem(AsyncBuildRecentProjectList, SD.FileService.RecentOpen.RecentProjects.ToArray());
}
void AsyncBuildRecentProjectList(object state)
{
var projectPaths = SD.FileService.RecentOpen.RecentProjects.ToArray();
List<RecentOpenItem> items = new List<RecentOpenItem>();
foreach (string path in (string[])state) {
Core.LoggingService.Debug("RecentProjectsControl: Looking up path '" + path + "'");
FileInfo file = new FileInfo(path);
if (file.Exists) {
items.Add(
new RecentOpenItem {
Name = Path.GetFileNameWithoutExtension(path),
LastModification = file.LastWriteTime.ToShortDateString(),
Path = path
});
}
}
await Task.Run(
delegate {
foreach (FileName path in projectPaths) {
Core.LoggingService.Debug("RecentProjectsControl: Looking up path '" + path + "'");
FileInfo file = new FileInfo(path);
if (file.Exists) {
items.Add(
new RecentOpenItem {
Name = Path.GetFileNameWithoutExtension(path),
LastModification = file.LastWriteTime.ToShortDateString(),
Path = path
});
}
}
});
if (items.Count > 0) {
SD.MainThread.InvokeAsyncAndForget(new Action(delegate {
lastProjectsListView.ItemsSource = items;
lastProjectsListView.Visibility = Visibility.Visible;
}));
lastProjectsListView.ItemsSource = items;
lastProjectsListView.Visibility = Visibility.Visible;
}
}

Loading…
Cancel
Save