public void BuyDrinkSync()
        {
            using (bus.AddInstanceSubscription(this))
            {
                wait = new ManualResetEvent(false);

                bus.Send(new NewOrder {
                    CustomerName = Name, DrinkName = Drink, Size = Size
                });

                if (wait.WaitOne(TimeSpan.FromSeconds(30), false) == false)
                {
                    throw new InvalidOperationException("didn't get my coffee in time");
                }
            }
        }
Esempio n. 2
0
        public int Execute <TCommand>(TCommand command) where TCommand : ICommand
        {
            var replyConsumer = new ReplyConsumer <TCommand>();

            using (serviceBus.AddInstanceSubscription(replyConsumer))
            {
                serviceBus.Send(new Request <TCommand> {
                    Command = command
                });
                if (!replyConsumer.Event.WaitOne(50000))
                {
                    throw new ExecuteTimeoutException();
                }

                return(replyConsumer.ValidationResult);
            }
        }