示例#1
0
 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));
     }
 }
示例#2
0
        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);
        }
示例#3
0
        public static void Run(Action action)
        {
            var ctxt = new SyncContextImpl();

            ctxt.RunCore(action, action.GetMethodInfo());
        }