コード例 #1
0
        public void Should_be_able_to_make_many_async_requests()
        {
            const int numberOfCalls  = 500;
            var       countdownEvent = new CountdownEvent(numberOfCalls);
            var       count          = 0;

            for (int i = 0; i < 1000; i++)
            {
                var request = new TestAsyncRequestMessage {
                    Text = "Hello async from the client! " + i
                };

                using (var publishChannel = bus.OpenPublishChannel())
                {
                    publishChannel.Request <TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                                                                                               response =>
                    {
                        Console.Out.WriteLine("response = {0}", response.Text);
                        Interlocked.Increment(ref count);
                        countdownEvent.Signal();
                    });
                }
            }
            countdownEvent.Wait(10000);
            count.ShouldEqual(numberOfCalls);
        }
コード例 #2
0
        public void Should_be_able_to_make_a_request_that_runs_async_on_the_server()
        {
            var request = new TestAsyncRequestMessage {
                Text = "Hello async from the client!"
            };

            Console.Out.WriteLine("Making request");
            bus.Request <TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                                                                            response => Console.Out.WriteLine("response = {0}", response.Text));

            Thread.Sleep(2000);
        }
コード例 #3
0
        public void Should_be_able_to_make_many_async_requests()
        {
            for (int i = 0; i < 1000; i++)
            {
                var request = new TestAsyncRequestMessage {
                    Text = "Hello async from the client! " + i
                };

                bus.Request <TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                                                                                response =>
                                                                                Console.Out.WriteLine("response = {0}", response.Text));
            }
            Thread.Sleep(5000);
        }
コード例 #4
0
        public void Should_be_able_to_make_a_request_that_runs_async_on_the_server()
        {
            var autoResetEvent = new AutoResetEvent(false);
            var request        = new TestAsyncRequestMessage {
                Text = "Hello async from the client!"
            };

            Console.Out.WriteLine("Making request");
            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.Request <TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                                                                                           response =>
                {
                    Console.Out.WriteLine("response = {0}", response.Text);
                    autoResetEvent.Set();
                });
            }

            autoResetEvent.WaitOne(2000);
        }
コード例 #5
0
        public void Should_be_able_to_make_many_async_requests()
        {
            for (int i = 0; i < 1000; i++)
            {
                var request = new TestAsyncRequestMessage { Text = "Hello async from the client! " + i };

                bus.Request<TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                    response =>
                    Console.Out.WriteLine("response = {0}", response.Text));
            }
            Thread.Sleep(5000);
        }
コード例 #6
0
        public void Should_be_able_to_make_a_request_that_runs_async_on_the_server()
        {
            var request = new TestAsyncRequestMessage {Text = "Hello async from the client!"};

            Console.Out.WriteLine("Making request");
            bus.Request<TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                response => Console.Out.WriteLine("response = {0}", response.Text));

            Thread.Sleep(2000);
        }
コード例 #7
0
        public void Should_be_able_to_make_many_async_requests()
        {
            const int numberOfCalls = 500;
            var countdownEvent = new CountdownEvent(numberOfCalls);
            var count = 0;

            for (int i = 0; i < 1000; i++)
            {
                var request = new TestAsyncRequestMessage { Text = "Hello async from the client! " + i };

                using (var publishChannel = bus.OpenPublishChannel())
                {
                    publishChannel.Request<TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                        response =>
                        {
                            Console.Out.WriteLine("response = {0}", response.Text);
                            Interlocked.Increment(ref count);
                            countdownEvent.Signal();
                        });
                }
            }
            countdownEvent.Wait(10000);
            count.ShouldEqual(numberOfCalls);
        }
コード例 #8
0
        public void Should_be_able_to_make_a_request_that_runs_async_on_the_server()
        {
            var autoResetEvent = new AutoResetEvent(false);
            var request = new TestAsyncRequestMessage {Text = "Hello async from the client!"};

            Console.Out.WriteLine("Making request");
            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.Request<TestAsyncRequestMessage, TestAsyncResponseMessage>(request,
                    response =>
                    {
                        Console.Out.WriteLine("response = {0}", response.Text);
                        autoResetEvent.Set();
                    });
            }

            autoResetEvent.WaitOne(2000);
        }