Browse Source

Don't catch exceptions in debug builds (makes debugging the decompiler easier)

pull/10/head
Daniel Grunwald 15 years ago
parent
commit
d0dc9538ef
  1. 26
      ILSpy/TextView/DecompilerTextView.cs

26
ILSpy/TextView/DecompilerTextView.cs

@ -254,22 +254,32 @@ namespace ICSharpCode.ILSpy.TextView
{ {
Debug.WriteLine("Start decompilation of {0} tree nodes", context.TreeNodes.Length); Debug.WriteLine("Start decompilation of {0} tree nodes", context.TreeNodes.Length);
TaskCompletionSource<AvalonEditTextOutput> tcs = new TaskCompletionSource<AvalonEditTextOutput>();
if (context.TreeNodes.Length == 0) { if (context.TreeNodes.Length == 0) {
// If there's nothing to be decompiled, don't bother starting up a thread. // If there's nothing to be decompiled, don't bother starting up a thread.
// (Improves perf in some cases since we don't have to wait for the thread-pool to accept our task) // (Improves perf in some cases since we don't have to wait for the thread-pool to accept our task)
TaskCompletionSource<AvalonEditTextOutput> tcs = new TaskCompletionSource<AvalonEditTextOutput>();
tcs.SetResult(new AvalonEditTextOutput()); tcs.SetResult(new AvalonEditTextOutput());
return tcs.Task; return tcs.Task;
} }
return Task.Factory.StartNew( Thread thread = new Thread(new ThreadStart(
delegate { delegate {
AvalonEditTextOutput textOutput = new AvalonEditTextOutput(); try {
textOutput.LengthLimit = outputLengthLimit; AvalonEditTextOutput textOutput = new AvalonEditTextOutput();
DecompileNodes(context, textOutput); textOutput.LengthLimit = outputLengthLimit;
textOutput.PrepareDocument(); DecompileNodes(context, textOutput);
return textOutput; textOutput.PrepareDocument();
}, TaskCreationOptions.LongRunning); tcs.SetResult(textOutput);
#if DEBUG
} catch (OperationCanceledException ex) {
#else
} catch (Exception ex) {
#endif
tcs.SetException(ex);
}
}));
thread.Start();
return tcs.Task;
} }
static void DecompileNodes(DecompilationContext context, ITextOutput textOutput) static void DecompileNodes(DecompilationContext context, ITextOutput textOutput)

Loading…
Cancel
Save