From 3516730165c0937511b5ab7f0016251c954f392b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 13 May 2010 11:54:16 +0000 Subject: [PATCH] StartPage: Move check if solution files still exist onto a background thread (solutions might be stored on slow network drive) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5815 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/RecentProjectsControl.xaml | 1 + .../Project/Src/RecentProjectsControl.xaml.cs | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml index 7a4661608b..679af6d8b5 100644 --- a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml +++ b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml @@ -8,6 +8,7 @@ SelectionMode="Single" core:SortableGridViewColumn.SortMode="Automatic" Margin="0,0,0,20" + Visibility="Collapsed" MouseDoubleClick="lastProjectsDoubleClick" KeyDown="lastProjectsKeyDown"> diff --git a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs index 09aff57357..935a00ba6e 100644 --- a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs +++ b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs @@ -7,14 +7,18 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.IO; +using System.Linq; +using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; - using ICSharpCode.Core.Presentation; using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.StartPage @@ -39,29 +43,45 @@ namespace ICSharpCode.StartPage set { SetValue(HeaderProperty, value); } } + 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, FileService.RecentOpen.RecentProject.ToArray()); + } + + void AsyncBuildRecentProjectList(object state) { List items = new List(); - foreach (string path in FileService.RecentOpen.RecentProject) { + foreach (string path in (string[])state) { FileInfo file = new FileInfo(path); if (file.Exists) { items.Add( new RecentOpenItem { - Name = System.IO.Path.GetFileNameWithoutExtension(path), + Name = Path.GetFileNameWithoutExtension(path), LastModification = file.LastWriteTime.ToShortDateString(), Path = path }); } } - lastProjectsListView.ItemsSource = items; - lastProjectsListView.Visibility = items.Count > 0 ? Visibility.Visible : Visibility.Collapsed; + if (items.Count > 0) { + WorkbenchSingleton.SafeThreadAsyncCall(new Action( + delegate { + lastProjectsListView.ItemsSource = items; + lastProjectsListView.Visibility = Visibility.Visible; + })); + } } - class RecentOpenItem + class RecentOpenItem : INotifyPropertyChanged { public string Name { get; set; } public string LastModification { get; set; } public string Path { get; set; } + + event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { } remove { } } } void lastProjectsDoubleClick(object sender, RoutedEventArgs e)