Exemple #1
0
        public Task <TResult> ProcessQuery <TQuery, TResult>(TQuery query) where TQuery : IAsyncQuery <object>
        {
            IScheduler scheduler;

            if (Schedulers.TryGetValue(typeof(TQuery), out scheduler))
            {
                return(scheduler.Run(() => _queryBus.ProcessQuery <TQuery, TResult>(query)));
            }
            if (DefaultScheduler != null)
            {
                return(DefaultScheduler.Run(() => _queryBus.ProcessQuery <TQuery, TResult>(query)));
            }
            return(_queryBus.ProcessQuery <TQuery, TResult>(query));
        }
        public Task ProcessCommand <TCommand>(TCommand command) where TCommand : IAsyncCommand
        {
            IScheduler scheduler;

            if (Schedulers.TryGetValue(typeof(TCommand), out scheduler))
            {
                return(scheduler.Run(() => _commandBus.ProcessCommand(command)));
            }
            if (DefaultScheduler != null)
            {
                return(DefaultScheduler.Run(() => _commandBus.ProcessCommand(command)));
            }
            return(_commandBus.ProcessCommand(command));
        }