Browse Source

fixed bug in FindAllParallel;

don't display stop button again, if search is loaded from history
pull/23/head
Siegfried Pammer 14 years ago
parent
commit
a72eb6c334
  1. 3
      src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs
  2. 13
      src/AddIns/Misc/SearchAndReplace/Project/Gui/DefaultSearchResult.cs

3
src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs

@ -159,11 +159,10 @@ namespace SearchAndReplace @@ -159,11 +159,10 @@ namespace SearchAndReplace
if (i >= taskCount) {
HandleResult(queue.Dequeue(), observer, exceptions, files);
}
if (exceptions.Count == 0) {
if (exceptions.Count > 0) break;
FileName file = files[i];
queue.Enqueue(System.Threading.Tasks.Task.Factory.StartNew(() => SearchFile(file)));
}
}
while (queue.Count > 0) {
HandleResult(queue.Dequeue(), observer, exceptions, files);
}

13
src/AddIns/Misc/SearchAndReplace/Project/Gui/DefaultSearchResult.cs

@ -142,6 +142,7 @@ namespace SearchAndReplace @@ -142,6 +142,7 @@ namespace SearchAndReplace
public class ObserverSearchResult : DefaultSearchResult, IObserver<SearchedFile>
{
Button stopButton;
bool finished;
public ObserverSearchResult(string title)
{
@ -164,18 +165,24 @@ namespace SearchAndReplace @@ -164,18 +165,24 @@ namespace SearchAndReplace
{
var items = base.GetToolbarItems();
if (!finished) {
stopButton = new Button { Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Debug.StopProcess") } };
stopButton.Click += StopButtonClick;
items.Add(stopButton);
stopButton.Visibility = Visibility.Visible;
}
return items;
}
void StopButtonClick(object sender, RoutedEventArgs e)
{
try {
stopButton.Visibility = Visibility.Hidden;
if (Registration != null) Registration.Dispose();
} finally {
finished = true;
}
}
void IObserver<SearchedFile>.OnNext(SearchedFile value)
@ -191,9 +198,13 @@ namespace SearchAndReplace @@ -191,9 +198,13 @@ namespace SearchAndReplace
void OnCompleted()
{
try {
stopButton.Visibility = Visibility.Collapsed;
if (Registration != null)
Registration.Dispose();
} finally {
finished = true;
}
}
void IObserver<SearchedFile>.OnCompleted()

Loading…
Cancel
Save