// running in Indexing or UI thread public void RunSearch(BackgroundSearcherParams searcherParams) { if (searcherParams.Path == null) { lock (this.BackgroundSearchers) { foreach (var sear in this.BackgroundSearchers) { sear.CancelAsync(); } this.BackgroundSearchers.Clear(); } } var searcher = new BackgroundSearcher(); searcher.RunWorkerCompleted += this.BackgroundSearcherWorkCompleted; if (searcherParams.Path != null) { searcher.RunWorkerSync(searcherParams); } else { searcher.RunWorkerAsync(searcherParams); lock (this.BackgroundSearchers) { this.BackgroundSearchers.Add(searcher); } } }
// running in Indexing or UI thread public void Execute(string path) { this.mainViewModel.AddNumOfSearchingThreads(1); if (path == null) { this.clearTreeViewCommand.Execute(); } var searcherParams = new BackgroundSearcherParams(this.documentHierarchyFactory.DocumentHierarchy, this.mainViewModel.SearchOptions, path); this.RunSearch(searcherParams); }
// running in Indexing or UI thread private void RunSearch(string path = null) { lock (this) { this.NumOfSearchingThreads++; } if (path == null) { this.ClearTreeView(); } var searcherParams = new BackgroundSearcherParams(this.DocumentHierarchySearcher, this.SearchOptions, path); this.IndexingSearchingModel.RunSearch(searcherParams); }