private void DoSearch(bool searchInResults = false) { SearchCriteria criteria = new SearchCriteria { SearchPath = SearchPath, FileTypes = FileTypes, SearchSopClassUid = SopClassUid, SearchTag = Tag, SearchText = SearchText, CaseSensitive = CaseSensitive, WholeWord = WholeWord, IncludeSubfolders = IncludeSubfolders, SearchInResults = searchInResults, // from parameter SearchThreads = SearchThreads }; Util.PushToList(SearchPath, SearchPathHistory, CurrentConfiguration.HistoryCapacity); Util.PushToList(FileTypes, FileTypesHistory, CurrentConfiguration.HistoryCapacity); Util.PushToList(SopClassUid, SopClassUidHistory, CurrentConfiguration.HistoryCapacity); Util.PushToList(Tag, DicomTagHistory, CurrentConfiguration.HistoryCapacity); Util.PushToList(SearchText, SearchTextHistory, CurrentConfiguration.HistoryCapacity); CurrentConfiguration.SearchCriteria = criteria; CurrentConfiguration.SearchPathHistory = new List <string>(SearchPathHistory); CurrentConfiguration.FileTypesHistory = new List <string>(FileTypesHistory); CurrentConfiguration.SopClassUidHistory = new List <string>(SopClassUidHistory); CurrentConfiguration.DicomTagHistory = new List <string>(DicomTagHistory); CurrentConfiguration.SearchTextHistory = new List <string>(SearchTextHistory); configurationService.Save(); MatchedFileList.Clear(); SelectedMatchedFile = null; this.TotalFileCount = 0; this.SearchedFileCount = 0; this.MatchedFileCount = 0; this.CanCancel = true; this.CanSearch = false; this.CanExport = false; tokenSource = new CancellationTokenSource(); // todo: move to SearchAsync() Task.Run(() => { this.searchService.Search(criteria, tokenSource); }, tokenSource.Token); }