示例#1
0
 public AfterInvokeArgs(PipeInvocation invocation, object state, bool isFaulted, Exception exception)
 {
     Invocation = invocation;
     State = state;
     IsFaulted = isFaulted;
     Exception = exception;
 }
示例#2
0
 public AfterInvokeArgs(PipeInvocation invocation, object?state, bool isFaulted, Exception?exception)
 {
     Invocation = invocation;
     State      = state;
     IsFaulted  = isFaulted;
     Exception  = exception;
 }
示例#3
0
 private static void DispatchSync(PipeInvocation invocation, MessageDispatch dispatch)
 {
     Exception exception = null;
     try
     {
         invocation.Run();
     }
     catch (Exception ex)
     {
         exception = ex;
     }
     dispatch.SetHandled(invocation.Invoker, exception);
 }
示例#4
0
        private void DispatchAsync(PipeInvocation invocation, MessageDispatch dispatch)
        {
            var invocationTask = invocation.RunAsync();
            invocationTask.ContinueWith(task => dispatch.SetHandled(invocation.Invoker, GetException(task)), TaskContinuationOptions.ExecuteSynchronously);

            if (invocationTask.Status != TaskStatus.Created)
                return;

            if (invocation.Invoker.ShouldCreateStartedTasks)
            {
                var exception = new InvalidProgramException(string.Format("{0}.Handle({1}) did not start the returned task", invocation.Invoker.MessageHandlerType.Name, invocation.Invoker.MessageType.Name));
                dispatch.SetHandled(invocation.Invoker, exception);
                return;
            }

            var taskScheduler = GetTaskScheduler(invocation.Invoker.DispatchQueueName);
            invocationTask.Start(taskScheduler);
        }