public static void RunWithWriteLock(Action action) { Exception actionException = null; #if !RESHARPER_31 TestShell.RunGuarded(delegate { using (WriteLockCookie.Create()) { #endif try { action(); } catch (Exception ex) { actionException = ex; } #if !RESHARPER_31 } }); #endif if (actionException != null) ExceptionUtils.RethrowWithNoStackTraceLoss(actionException); }
/// <summary> /// Temporarily disables exception logging. /// </summary> /// <param name="bugExplanation">An explanation of the bug that we are working around.</param> /// <param name="action">The action to perform.</param> public static void Suppress(string bugExplanation, Action action) { try { lock (syncRoot) { if (++nesting == 1) { initialSetting = Logger.AllowExceptions; Logger.AllowExceptions = true; } } action(); } #if RESHARPER_31 catch (InternalErrorException ex) #else catch (LoggerException ex) #endif { throw new InternalErrorException(bugExplanation, ex); } finally { lock (syncRoot) { if (--nesting == 0) { Logger.AllowExceptions = initialSetting; } } } }
/// <summary> /// Temporarily disables exception logging. /// </summary> /// <param name="bugExplanation">An explanation of the bug that we are working around.</param> /// <param name="action">The action to perform.</param> public static void Suppress(string bugExplanation, Action action) { try { lock (syncRoot) { if (++nesting == 1) { initialSetting = Logger.AllowExceptions; Logger.AllowExceptions = true; } } action(); } #if RESHARPER_31 catch (InternalErrorException ex) #else catch (LoggerException ex) #endif { throw new InternalErrorException(bugExplanation, ex); } finally { lock (syncRoot) { if (--nesting == 0) Logger.AllowExceptions = initialSetting; } } }