//make async private async void Button_Click(object sender, RoutedEventArgs e) { //for (int i = 0; i < 40; i++) //{ // await Task.Delay(100); // Output.Text += $"Text{i}\n"; //} if (SpecifiedWord.Text == "Type Here" || SelectedFolder.Text == string.Empty) { MessageBox.Show("Please enter valid File Name or choose a valid folder!"); } else { DirectoryInfo dirInfo = new DirectoryInfo(_selectedPath); await Task.Run(() => searcher.Iterate(dirInfo, target)); if (searcher.Iterate(dirInfo, target)) { Status.Visibility = Visibility.Visible; Status.Text = "Found"; FoundAtText.Visibility = Visibility.Visible; foundAt.Visibility = Visibility.Visible; FoundAt.Visibility = Visibility.Visible; FoundAt.Text = searcher.GetDirectory(); OpenFolder.Visibility = Visibility.Visible; EditFile.Visibility = Visibility.Visible; } else { Status.Visibility = Visibility.Visible; Status.Text = "NotFound"; } } }