public async Task Search(string text) { await Dispatcher.CurrentDispatcher.InvokeAsync(ClearSearch); searchCanceler.Cancel(); retry: await FileSearcher.TraverseTree(CurrentPath, text, UpdateSearch, searchCanceler.Token); if (searchCanceler.IsCancellationRequested) { searchCanceler = new CancellationTokenSource(); if (!(text == null || text == string.Empty)) { goto retry; } } if (text == null || text == string.Empty) { await Dispatcher.CurrentDispatcher.InvokeAsync(ClearSearch); OpenDirectory(CurrentPath); } searchCanceler = new CancellationTokenSource(); }
private void SearchClick(object sender, RoutedEventArgs e) { string content = SearchBox.Text; if (!String.IsNullOrEmpty(content)) { FileSearcher searcher = new FileSearcher(); string format = ""; GetCurrentExtension(ref format); if (format == "*.txt" || format == "*.html" || format == "*.xml") { searcher.Search(CurrentLocation ?? DriversBox.SelectedItem.ToString(), format, content, (Button)sender); } else { MessageBox.Show("Поиск по заданым параметрам невозможен"); } } }