コード例 #1
0
 public override Task InvokeMessageHandlerAsync(IMessageHandlerInvocation invocation)
 {
     try
     {
         var handler = CreateHandler(_container, invocation.Context);
         using (invocation.SetupForInvocation(handler))
         {
             return(_handleAction(handler, invocation.Messages[0]));
         }
     }
     catch (Exception ex)
     {
         return(TaskUtil.FromError(ex));
     }
 }
コード例 #2
0
        protected internal virtual Task RunAsync()
        {
            var pipeStates = BeforeInvoke();

            var runTask = _invoker.InvokeMessageHandlerAsync(this);

            if (runTask.Status == TaskStatus.Created)
            {
                var exception = new InvalidProgramException($"{Invoker.MessageHandlerType.Name}.Handle({Invoker.MessageType.Name}) did not start the returned task");
                runTask = TaskUtil.FromError(exception);
            }

            runTask.ContinueWith(task => AfterInvoke(pipeStates, task.IsFaulted, task.Exception), TaskContinuationOptions.ExecuteSynchronously);

            return(runTask);
        }