public static T InvokeRethrow <T>(this DbgDotNetDispatcher dispatcher, Func <T> callback) { ExceptionDispatchInfo exceptionInfo = null; var res = dispatcher.Invoke(() => { T res2; try { res2 = callback(); } catch (Exception ex) { exceptionInfo = ExceptionDispatchInfo.Capture(ex); res2 = default; } return(res2); }); exceptionInfo?.Throw(); return(res); }
public static bool TryInvokeRethrow <T>(this DbgDotNetDispatcher dispatcher, Func <T> callback, out T result) { ExceptionDispatchInfo exceptionInfo = null; bool success = dispatcher.TryInvoke(() => { T res2; try { res2 = callback(); } catch (Exception ex) { exceptionInfo = ExceptionDispatchInfo.Capture(ex); res2 = default; } return(res2); }, out result); exceptionInfo?.Throw(); return(success); }
public static void InvokeRethrow(this DbgDotNetDispatcher dispatcher, Action callback) => dispatcher.InvokeRethrow <object>(() => { callback(); return(null); });
public static bool TryInvokeRethrow(this DbgDotNetDispatcher dispatcher, Action callback) => dispatcher.TryInvokeRethrow <object?>(() => { callback(); return(null); }, out _);