public MainViewModel() { SearchResultsCollection = new ObservableCollection <DocumentData>(); SearchString = string.Empty; SearchCommand = new DelegateCommand(SearchCommand_CanExecute, SearchCommand_Execute); //Task.Factory.StartNew(() => //{ var dataLocation = ConfigurationManager.AppSettings.Get("DataLocation"); var indexLocation = ConfigurationManager.AppSettings.Get("IndexLocation"); var documentDataList = _fileScanner.GetFileListWithFullPath(dataLocation); _searchManager.BuildIndex(new SearchContext { IndexPath = indexLocation, ScanPath = dataLocation }, documentDataList); //}); }
/// <summary> /// Build Index from stratch /// </summary> private void BuildIndex() { Task.Factory.StartNew(() => { var dataLocation = ConfigurationManager.AppSettings.Get("DataLocation"); var indexLocation = ConfigurationManager.AppSettings.Get("IndexLocation"); Stopwatch sw = new Stopwatch(); sw.Start(); _searchManager.BuildIndex(new SearchContext { IndexPath = indexLocation, ScanPath = dataLocation }); sw.Stop(); Trace.WriteLine(string.Format("Time taken to build index {0}", sw.Elapsed.ToString())); //MessageBox.Show(string.Format("Time taken to re-build index {0}", sw.Elapsed.ToString())); }).ContinueWith((t) => { SearchCommand_Execute(new object()); }, TaskContinuationOptions.OnlyOnRanToCompletion).ContinueWith((t2) => { MessageBox.Show("Settings saved, Index rebuilt, Search refreshed !!"); }); }