Beispiel #1
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($"{invocation.Invoker.MessageHandlerType.Name}.Handle({invocation.Invoker.MessageType.Name}) did not start the returned task");
                dispatch.SetHandled(invocation.Invoker, exception);
                return;
            }

            var taskScheduler = GetTaskScheduler(invocation.Invoker.DispatchQueueName);

            invocationTask.Start(taskScheduler);
        }
Beispiel #2
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);
        }
Beispiel #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);
 }
Beispiel #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);
        }