From d0dc9538ef0f782828d423c6d7af188341171188 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 12 Feb 2011 21:49:03 +0100 Subject: [PATCH] Don't catch exceptions in debug builds (makes debugging the decompiler easier) --- ILSpy/TextView/DecompilerTextView.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index 648a9dbd9..55204e511 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -254,22 +254,32 @@ namespace ICSharpCode.ILSpy.TextView { Debug.WriteLine("Start decompilation of {0} tree nodes", context.TreeNodes.Length); + TaskCompletionSource tcs = new TaskCompletionSource(); if (context.TreeNodes.Length == 0) { // 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) - TaskCompletionSource tcs = new TaskCompletionSource(); tcs.SetResult(new AvalonEditTextOutput()); return tcs.Task; } - return Task.Factory.StartNew( + Thread thread = new Thread(new ThreadStart( delegate { - AvalonEditTextOutput textOutput = new AvalonEditTextOutput(); - textOutput.LengthLimit = outputLengthLimit; - DecompileNodes(context, textOutput); - textOutput.PrepareDocument(); - return textOutput; - }, TaskCreationOptions.LongRunning); + try { + AvalonEditTextOutput textOutput = new AvalonEditTextOutput(); + textOutput.LengthLimit = outputLengthLimit; + DecompileNodes(context, textOutput); + textOutput.PrepareDocument(); + 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)