示例#1
0
 private void DispatchStepAsync(
     ExecuteStepCommand command)
 {
     Task.Run(async() =>
     {
         try
         {
             await DispatchStepSync(command);
         }
         catch (Exception ex)
         {
             await asyncErrorHandler.Handle(command.Saga, ex);
         }
     });
 }
        private void DispatchStepAsync(
            ExecuteStepCommand command)
        {
            Task.Run(async() =>
            {
                try
                {
                    using (IServiceScope scope = serviceScopeFactory.CreateScope())
                    {
                        // when Saga is forced to run asynchronously, then it can be resumed
                        if (command?.Saga?.ExecutionState != null)
                        {
                            command.Saga.ExecutionState.CanBeResumed = true;
                        }

                        await DispatchStepSync(scope.ServiceProvider, command);
                    }
                }
                catch (Exception ex)
                {
                    await asyncErrorHandler.Handle(command.Saga, ex);
                }
            });
        }