Browse Source

Fix cancellation.

Closes #303; closes #313.
pull/320/merge
Daniel Grunwald 13 years ago
parent
commit
ba80bb0089
  1. 2
      ILSpy.BamlDecompiler/BamlResourceEntryNode.cs
  2. 2
      ILSpy/Commands/DecompileAllCommand.cs
  3. 26
      ILSpy/TextView/DecompilerTextView.cs
  4. 2
      ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs
  5. 2
      ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

2
ILSpy.BamlDecompiler/BamlResourceEntryNode.cs

@ -39,7 +39,7 @@ namespace ILSpy.BamlDecompiler
output.Write(ex.ToString()); output.Write(ex.ToString());
} }
return output; return output;
}), }, token),
t => textView.ShowNode(t.Result, this, highlighting) t => textView.ShowNode(t.Result, this, highlighting)
); );
return true; return true;

2
ILSpy/Commands/DecompileAllCommand.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.ILSpy
} }
}); });
return output; return output;
}), task => MainWindow.Instance.TextView.ShowText(task.Result)); }, ct), task => MainWindow.Instance.TextView.ShowText(task.Result));
} }
} }
} }

26
ILSpy/TextView/DecompilerTextView.cs

@ -261,7 +261,13 @@ namespace ICSharpCode.ILSpy.TextView
if (currentCancellationTokenSource == myCancellationTokenSource) { if (currentCancellationTokenSource == myCancellationTokenSource) {
currentCancellationTokenSource = null; currentCancellationTokenSource = null;
waitAdorner.Visibility = Visibility.Collapsed; waitAdorner.Visibility = Visibility.Collapsed;
taskCompleted(task); if (task.IsCanceled) {
AvalonEditTextOutput output = new AvalonEditTextOutput();
output.WriteLine("The operation was canceled.");
ShowOutput(output);
} else {
taskCompleted(task);
}
} else { } else {
try { try {
task.Wait(); task.Wait();
@ -480,8 +486,8 @@ namespace ICSharpCode.ILSpy.TextView
if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token)) if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token))
return; return;
if (!DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(ilOffset, out member, out line)) if (!DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(ilOffset, out member, out line))
return; return;
// update marker // update marker
DebuggerService.JumpToCurrentLine(member, line, 0, line, 0, ilOffset); DebuggerService.JumpToCurrentLine(member, line, 0, line, 0, ilOffset);
@ -520,10 +526,12 @@ namespace ICSharpCode.ILSpy.TextView
DecompileNodes(context, textOutput); DecompileNodes(context, textOutput);
textOutput.PrepareDocument(); textOutput.PrepareDocument();
tcs.SetResult(textOutput); tcs.SetResult(textOutput);
} catch (AggregateException ex) { } catch (OutputLengthExceededException ex) {
tcs.SetException(ex); tcs.SetException(ex);
} catch (OperationCanceledException ex) { } catch (AggregateException ex) {
tcs.SetException(ex); tcs.SetException(ex);
} catch (OperationCanceledException) {
tcs.SetCanceled();
} }
} else } else
#endif #endif
@ -534,6 +542,8 @@ namespace ICSharpCode.ILSpy.TextView
DecompileNodes(context, textOutput); DecompileNodes(context, textOutput);
textOutput.PrepareDocument(); textOutput.PrepareDocument();
tcs.SetResult(textOutput); tcs.SetResult(textOutput);
} catch (OperationCanceledException) {
tcs.SetCanceled();
} catch (Exception ex) { } catch (Exception ex) {
tcs.SetException(ex); tcs.SetException(ex);
} }
@ -586,7 +596,7 @@ namespace ICSharpCode.ILSpy.TextView
output.WriteLine(); output.WriteLine();
} }
#endregion #endregion
#region JumpToReference #region JumpToReference
/// <summary> /// <summary>
/// Jumps to the definition referred to by the <see cref="ReferenceSegment"/>. /// Jumps to the definition referred to by the <see cref="ReferenceSegment"/>.
@ -717,9 +727,9 @@ namespace ICSharpCode.ILSpy.TextView
output.AddButton(null, "Open Explorer", delegate { Process.Start("explorer", "/select,\"" + fileName + "\""); }); output.AddButton(null, "Open Explorer", delegate { Process.Start("explorer", "/select,\"" + fileName + "\""); });
output.WriteLine(); output.WriteLine();
tcs.SetResult(output); tcs.SetResult(output);
#if DEBUG
} catch (OperationCanceledException ex) { } catch (OperationCanceledException ex) {
tcs.SetException(ex); tcs.SetCanceled();
#if DEBUG
} catch (AggregateException ex) { } catch (AggregateException ex) {
tcs.SetException(ex); tcs.SetException(ex);
#else #else

2
ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.ILSpy.Xaml
output.Write(ex.ToString()); output.Write(ex.ToString());
} }
return output; return output;
}), }, token),
t => textView.ShowNode(t.Result, this, highlighting) t => textView.ShowNode(t.Result, this, highlighting)
); );
return true; return true;

2
ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

@ -101,7 +101,7 @@ namespace ICSharpCode.ILSpy.Xaml
output.Write(ex.ToString()); output.Write(ex.ToString());
} }
return output; return output;
}), }, token),
t => textView.ShowNode(t.Result, this, highlighting) t => textView.ShowNode(t.Result, this, highlighting)
); );
return true; return true;

Loading…
Cancel
Save