Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bug in FindAllParallel;

don't display stop button again, if search is loaded from history
  • Loading branch information...
commit a72eb6c334297fc422a2c0b66261771aa8d893a6 1 parent 6d3c9c0
@siegfriedpammer siegfriedpammer authored
View
7 src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchManager.cs
@@ -159,10 +159,9 @@ void SearchParallel(List<FileName> files, IObserver<SearchedFile> observer)
if (i >= taskCount) {
HandleResult(queue.Dequeue(), observer, exceptions, files);
}
- if (exceptions.Count == 0) {
- FileName file = files[i];
- queue.Enqueue(System.Threading.Tasks.Task.Factory.StartNew(() => SearchFile(file)));
- }
+ 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);
View
29 src/AddIns/Misc/SearchAndReplace/Project/Gui/DefaultSearchResult.cs
@@ -142,6 +142,7 @@ public ISearchResult CreateSearchResult(string title, IObservable<SearchedFile>
public class ObserverSearchResult : DefaultSearchResult, IObserver<SearchedFile>
{
Button stopButton;
+ bool finished;
public ObserverSearchResult(string title)
{
@@ -164,18 +165,24 @@ public override IList GetToolbarItems()
{
var items = base.GetToolbarItems();
- stopButton = new Button { Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Debug.StopProcess") } };
- stopButton.Click += StopButtonClick;
+ if (!finished) {
+ stopButton = new Button { Content = new Image { Height = 16, Source = PresentationResourceService.GetBitmapSource("Icons.16x16.Debug.StopProcess") } };
+ stopButton.Click += StopButtonClick;
+
+ items.Add(stopButton);
+ }
- items.Add(stopButton);
- stopButton.Visibility = Visibility.Visible;
return items;
}
void StopButtonClick(object sender, RoutedEventArgs e)
{
- stopButton.Visibility = Visibility.Hidden;
- if (Registration != null) Registration.Dispose();
+ try {
+ stopButton.Visibility = Visibility.Hidden;
+ if (Registration != null) Registration.Dispose();
+ } finally {
+ finished = true;
+ }
}
void IObserver<SearchedFile>.OnNext(SearchedFile value)
@@ -191,9 +198,13 @@ void IObserver<SearchedFile>.OnError(Exception error)
void OnCompleted()
{
- stopButton.Visibility = Visibility.Collapsed;
- if (Registration != null)
- Registration.Dispose();
+ try {
+ stopButton.Visibility = Visibility.Collapsed;
+ if (Registration != null)
+ Registration.Dispose();
+ } finally {
+ finished = true;
+ }
}
void IObserver<SearchedFile>.OnCompleted()
Please sign in to comment.
Something went wrong with that request. Please try again.