Browse Source

- Properly reset AnalyzerSearchTreeNode on assembly list changes.

- Add a stopwatch to ThreadingSupport
pull/2606/head
Siegfried Pammer 4 years ago
parent
commit
9d264f56d6
  1. 5
      ILSpy/Analyzers/AnalyzerSearchTreeNode.cs
  2. 15
      ILSpy/TreeNodes/ThreadingSupport.cs

5
ILSpy/Analyzers/AnalyzerSearchTreeNode.cs

@ -42,7 +42,8 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -42,7 +42,8 @@ namespace ICSharpCode.ILSpy.Analyzers
this.analyzerHeader = analyzerHeader;
}
public override object Text => analyzerHeader + (Children.Count > 0 ? " (" + Children.Count + ")" : "");
public override object Text => analyzerHeader
+ (Children.Count > 0 && !threading.IsRunning ? " (" + Children.Count + ") in " + threading.EllapsedMilliseconds + "ms" : "");
public override object Icon => Images.Search;
@ -117,6 +118,7 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -117,6 +118,7 @@ namespace ICSharpCode.ILSpy.Analyzers
this.LazyLoading = true;
threading.Cancel();
this.Children.Clear();
RaisePropertyChanged(nameof(Text));
}
}
@ -134,6 +136,7 @@ namespace ICSharpCode.ILSpy.Analyzers @@ -134,6 +136,7 @@ namespace ICSharpCode.ILSpy.Analyzers
this.LazyLoading = true;
threading.Cancel();
this.Children.Clear();
RaisePropertyChanged(nameof(Text));
}
return true;
}

15
ILSpy/TreeNodes/ThreadingSupport.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
@ -37,18 +38,22 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -37,18 +38,22 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
class ThreadingSupport
{
Task<List<SharpTreeNode>> loadChildrenTask;
readonly Stopwatch stopwatch = new Stopwatch();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
Task<List<SharpTreeNode>> loadChildrenTask;
public bool IsRunning {
get { return loadChildrenTask != null && !loadChildrenTask.IsCompleted; }
}
public long EllapsedMilliseconds => stopwatch.ElapsedMilliseconds;
public void Cancel()
{
cancellationTokenSource.Cancel();
loadChildrenTask = null;
cancellationTokenSource = new CancellationTokenSource();
stopwatch.Reset();
}
/// <summary>
@ -56,6 +61,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -56,6 +61,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
public void LoadChildren(SharpTreeNode node, Func<CancellationToken, IEnumerable<SharpTreeNode>> fetchChildren)
{
stopwatch.Restart();
node.Children.Add(new LoadingTreeNode());
CancellationToken ct = cancellationTokenSource.Token;
@ -89,12 +95,11 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -89,12 +95,11 @@ namespace ICSharpCode.ILSpy.TreeNodes
delegate {
if (loadChildrenTask == thisTask)
{
stopwatch.Stop();
node.Children.RemoveAt(node.Children.Count - 1); // remove 'Loading...'
node.RaisePropertyChanged(nameof(node.Text));
}
if (continuation.Exception != null)
{ // observe exception even when task isn't current
if (loadChildrenTask == thisTask)
if (continuation.Exception != null)
{
foreach (Exception ex in continuation.Exception.InnerExceptions)
{

Loading…
Cancel
Save