public static Exception Exception(Action action, RecordExceptionFlags flags) { try { SyncContextImpl.Run(action); return(null); } catch (Exception ex) { if (ex is AssertException && flags.HasFlag(RecordExceptionFlags.IgnoreAssertExceptions)) { throw; } return(ApplyFlags(ex, flags)); } }
public static object Run(MethodInfo method, object o, object[] args) { var ctxt = new SyncContextImpl(); object result = null; Action action = () => { result = method.Invoke(o, args); var task = result as Task; if (task != null) { task.GetAwaiter().OnCompleted(ctxt.OperationCompleted); result = TaskHelper.ResultOf(task); } }; ctxt.RunCore(action, method); return(result); }
public static void Run(Action action) { var ctxt = new SyncContextImpl(); ctxt.RunCore(action, action.GetMethodInfo()); }