Esempio n. 1
0
        public IAsyncResult BeginSend <T>(T command, Action <CommandResult> action, int timeoutInSec = 30) where T : DomainCommand
        {
            var callback = new AsyncCallback(result => action((CommandResult)result.AsyncState));

            return(_serviceBus.BeginPublishRequest(new QueryCommand <T>(command), callback, null, context =>
            {
                context.Handle <CommandResult>(commandResult => new AsyncResult(callback, commandResult));
                context.SetTimeout(new TimeSpan(0, 0, timeoutInSec));
            }));
        }