Skip to content

Commit 020cb20

Browse files
committed
Set busy state back to false after OperationCanceledException. Closes #4596
1 parent ea6c2e8 commit 020cb20

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
373373
private async void RefreshInspections(CancellationToken token)
374374
{
375375
var stopwatch = Stopwatch.StartNew();
376-
// TODO sort out busy state.
377376
IsBusy = true;
378377

379378
List<IInspectionResult> results;
@@ -385,33 +384,40 @@ private async void RefreshInspections(CancellationToken token)
385384
catch (OperationCanceledException)
386385
{
387386
Logger.Debug("Inspections got canceled.");
387+
IsBusy = false;
388388
return; //We throw away the partial results.
389389
}
390390

391+
stopwatch.Stop();
392+
LogManager.GetCurrentClassLogger().Trace("Inspection results returned in {0}ms", stopwatch.ElapsedMilliseconds);
393+
391394
_uiDispatcher.Invoke(() =>
392395
{
393-
_results.Clear();
394-
foreach (var result in results)
395-
{
396-
_results.Add(result);
397-
}
398-
399-
Results.Refresh();
400-
396+
stopwatch = Stopwatch.StartNew();
401397
try
402398
{
403-
IsBusy = false;
404-
IsRefreshing = false;
399+
_results.Clear();
400+
foreach (var result in results)
401+
{
402+
_results.Add(result);
403+
}
404+
405+
Results.Refresh();
405406
SelectedItem = null;
406407
}
407408
catch (Exception exception)
408409
{
409410
Logger.Error(exception, "Exception thrown trying to refresh the inspection results view on th UI thread.");
410411
}
411-
});
412+
finally
413+
{
414+
IsBusy = false;
415+
IsRefreshing = false;
416+
}
412417

413-
stopwatch.Stop();
414-
LogManager.GetCurrentClassLogger().Trace("Inspections loaded in {0}ms", stopwatch.ElapsedMilliseconds);
418+
stopwatch.Stop();
419+
LogManager.GetCurrentClassLogger().Trace("Inspection results rendered in {0}ms", stopwatch.ElapsedMilliseconds);
420+
});
415421
}
416422

417423
private void InvalidateStaleInspectionResults(ICollection<QualifiedModuleName> modifiedModules)

0 commit comments

Comments
 (0)